Skip to main content

ServeCommand

Enum ServeCommand 

Source
pub enum ServeCommand {
    Status {
        checkouts: Checkouts,
        format: OutputFormat,
    },
    Ensure {
        port: Option<u16>,
        idle: Option<u64>,
        wait: u64,
        format: OutputFormat,
    },
    Stop {
        wait: u64,
    },
}
Expand description

The subcommands of majordomus serve: the server’s lifecycle as something a person or a hook converges on rather than remembers. status is the projection of server.status; ensure and stop are process lifecycle, which no capability served by the process could be.

use clap::Parser;
use majordomus_cli::capability::builtin::Checkouts;
use majordomus_cli::cli::{Cli, Command, ServeCommand};

let cli = Cli::try_parse_from(["majordomus", "serve", "ensure", "--idle", "5"]).unwrap();
let Command::Serve(args) = cli.command else { panic!("serve") };
assert!(matches!(args.command, Some(ServeCommand::Ensure { idle: Some(5), .. })));

// without `--idle`, `ensure` names no idle life: the declared `server.idle_seconds:`
// decides, and `DEFAULT_IDLE_SECONDS` when nothing is declared (I2701)
let cli = Cli::try_parse_from(["majordomus", "serve", "ensure"]).unwrap();
let Command::Serve(args) = cli.command else { panic!("serve") };
assert!(matches!(args.command, Some(ServeCommand::Ensure { idle: None, .. })));

// without a subcommand, `serve` serves; the defaults are the documented ones
let cli = Cli::try_parse_from(["majordomus", "serve"]).unwrap();
let Command::Serve(args) = cli.command else { panic!("serve") };
assert!(args.command.is_none() && args.idle == 0 && !args.fallback);

// `status` asks the capability's own question, and the flag is that input's field:
// saying nothing asks about every checkout of the repository, as it always did
let cli = Cli::try_parse_from(["majordomus", "serve", "status"]).unwrap();
let Command::Serve(args) = cli.command else { panic!("serve") };
assert!(matches!(args.command, Some(ServeCommand::Status { checkouts: Checkouts::Repository, .. })));
let cli = Cli::try_parse_from(["majordomus", "serve", "status", "--checkouts", "this"]).unwrap();
let Command::Serve(args) = cli.command else { panic!("serve") };
assert!(matches!(args.command, Some(ServeCommand::Status { checkouts: Checkouts::This, .. })));

Variants§

§

Status

Where this checkout’s server stands — absent, starting, ready, outdated or stale — and every server of the repository

Fields

§checkouts: Checkouts

Which checkouts to answer for: every checkout of the repository, or this one alone — which reads no other checkout’s lease and probes no other server

§format: OutputFormat

Output shape

§

Ensure

Make sure a ready server serves this checkout: start one when there is none or the lease is stale, wait for one that is starting, and report where it stands

Fields

§port: Option<u16>

The port the started server asks for first, without it the one this checkout derives (8741 for the primary checkout); a taken one is replaced by a free one

§idle: Option<u64>

The started server stops when no peer has been attached for this many seconds; without it, the policy’s declared server.idle_seconds, 900 when none is declared

§wait: u64

How long to wait for a server to become ready before reporting what stands

§format: OutputFormat

Output shape

§

Stop

Stop this checkout’s server — the one its lease names, when it answers for this checkout — and wait for that server’s lease to go, which another process taking the checkout over does not undo

Fields

§wait: u64

How long to wait for the server to end

Trait Implementations§

Source§

impl Debug for ServeCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for ServeCommand

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Subcommand for ServeCommand

Source§

fn augment_subcommands<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self via [FromArgMatches::from_arg_matches_mut] Read more
Source§

fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate self via [FromArgMatches::update_from_arg_matches_mut] Read more
Source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more