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: CheckoutsWhich 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: OutputFormatOutput 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
format: OutputFormatOutput 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
Trait Implementations§
Source§impl Debug for ServeCommand
impl Debug for ServeCommand
Source§impl FromArgMatches for ServeCommand
impl FromArgMatches for ServeCommand
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut<'b>(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Subcommand for ServeCommand
impl Subcommand for ServeCommand
Source§fn augment_subcommands<'b>(__clap_app: Command) -> Command
fn augment_subcommands<'b>(__clap_app: Command) -> Command
Source§fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
Command] so it can instantiate self via
[FromArgMatches::update_from_arg_matches_mut] Read moreSource§fn has_subcommand(__clap_name: &str) -> bool
fn has_subcommand(__clap_name: &str) -> bool
Self can parse a specific subcommand