diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-10 10:32:24 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-10 11:48:45 +0100 |
commit | 0ecac14b26d6eea26328aefff1c4e88d25cd643c (patch) | |
tree | ba35fcf8ccbdc36384794826dfb7b05918351580 /src/cli.rs | |
parent | a554772d25026a9cf223514d9422c70fc9b15f69 (diff) | |
parent | 9a79643ced98567ab7b0c742f0d161cb5dd43578 (diff) |
Merge branch 'subcommand-endpoint'
Conflicts:
src/cli.rs
src/main.rs
from merging the "metrics" subcommand implementation branch first.
Conflicts were trivial, so I resolved them here in the merge commit.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 207 |
1 files changed, 207 insertions, 0 deletions
@@ -837,6 +837,209 @@ pub fn cli<'a>() -> App<'a> { .version(crate_version!()) .about("Print metrics about butido") ) + + .subcommand(App::new("endpoint") + .version(crate_version!()) + .about("Endpoint maintentance commands") + .arg(Arg::new("endpoint_name") + .required(false) + .multiple(false) + .index(1) + .value_name("ENDPOINT_NAME") + .about("Endpoint to talk to, or all if not given") + ) + + .subcommand(App::new("ping") + .version(crate_version!()) + .about("Ping the endpoint(s)") + .arg(Arg::new("ping_n") + .required(false) + .multiple(false) + .long("times") + .short('n') + .value_name("N") + .default_value("10") + .about("How often to ping") + ) + .arg(Arg::new("ping_sleep") + .required(false) + .multiple(false) + .long("sleep") + .value_name("N") + .default_value("1") + .about("How long to sleep between pings") + ) + ) + .subcommand(App::new("stats") + .version(crate_version!()) + .about("Get stats for the endpoint(s)") + .arg(Arg::new("csv") + .required(false) + .multiple(false) + .long("csv") + .takes_value(false) + .about("Format output as CSV") + ) + ) + .subcommand(App::new("containers") + .version(crate_version!()) + .about("Work with the containers of the endpoint(s)") + .subcommand(App::new("prune") + .version(crate_version!()) + .about("Remove exited containers") + .arg(Arg::new("older_than") + .required(false) + .multiple(false) + .long("older-than") + .takes_value(true) + .value_name("DATE") + .about("List only containers that are older than DATE") + .validator(parse_date_from_string) + .conflicts_with("newer_than") + ) + + .arg(Arg::new("newer_than") + .required(false) + .multiple(false) + .long("newer-than") + .takes_value(true) + .value_name("DATE") + .about("List only containers that are newer than DATE") + .validator(parse_date_from_string) + .conflicts_with("older_than") + ) + ) + .subcommand(App::new("list") + .version(crate_version!()) + .about("List the containers and stats about them") + .arg(Arg::new("csv") + .required(false) + .multiple(false) + .long("csv") + .takes_value(false) + .about("Format output as CSV") + ) + + .arg(Arg::new("list_stopped") + .required(false) + .multiple(false) + .long("list-stopped") + .takes_value(false) + .about("List stopped containers too") + ) + + .arg(Arg::new("filter_image") + .required(false) + .multiple(false) + .long("image") + .takes_value(true) + .value_name("IMAGE") + .about("List only containers of IMAGE") + ) + + .arg(Arg::new("older_than") + .required(false) + .multiple(false) + .long("older-than") + .takes_value(true) + .value_name("DATE") + .about("List only containers that are older than DATE") + .validator(parse_date_from_string) + .conflicts_with("newer_than") + ) + + .arg(Arg::new("newer_than") + .required(false) + .multiple(false) + .long("newer-than") + .takes_value(true) + .value_name("DATE") + .about("List only containers that are newer than DATE") + .validator(parse_date_from_string) + .conflicts_with("older_than") + ) + ) + ) + .subcommand(App::new("container") + .version(crate_version!()) + .about("Work with a specific container") + .arg(Arg::new("container_id") + .required(true) + .multiple(false) + .index(1) + .takes_value(true) + .value_name("CONTAINER_ID") + .about("Work with container CONTAINER_ID") + ) + .subcommand(App::new("top") + .version(crate_version!()) + .about("List the container processes") + .arg(Arg::new("csv") + .required(false) + .multiple(false) + .long("csv") + .takes_value(false) + .about("List top output as CSV") + ) + ) + .subcommand(App::new("kill") + .version(crate_version!()) + .about("Kill the container") + .arg(Arg::new("signal") + .required(false) + .multiple(false) + .index(1) + .takes_value(true) + .value_name("SIGNAL") + .about("Kill container with this signal") + ) + ) + .subcommand(App::new("delete") + .version(crate_version!()) + .about("Delete the container") + ) + .subcommand(App::new("start") + .version(crate_version!()) + .about("Start the container") + ) + .subcommand(App::new("stop") + .version(crate_version!()) + .about("Stop the container") + .arg(Arg::new("timeout") + .required(false) + .multiple(false) + .long("timeout") + .takes_value(true) + .value_name("DURATION") + .about("Timeout") + ) + ) + .subcommand(App::new("exec") + .version(crate_version!()) + .about("Execute commands in the container") + .arg(Arg::new("commands") + .required(true) + .multiple(true) + .index(1) + .takes_value(true) + .value_name("CMD") + .about("Commands to execute in the container") + .long_about(indoc::indoc!(r#" + Execute a command in the container. + + This does not handle TTY forwarding, so you cannot execute interactive commands in the container (e.g. htop). + For executing interactive things, you have to login to the container. + "#)) + ) + ) + + .subcommand(App::new("inspect") + .version(crate_version!()) + .about("Display details about the container") + .long_about("Display details about the container. Do not assume the output format to be stable.") + ) + ) + ) } fn script_arg_line_numbers<'a>() -> clap::Arg<'a> { @@ -914,6 +1117,10 @@ fn dir_exists_validator(s: &str) -> Result<(), String> { } } +fn parse_date_from_string(s: &str) -> std::result::Result<(), String> { + humantime::parse_rfc3339_weak(s).map_err(|e| e.to_string()).map(|_| ()) +} + #[cfg(test)] mod tests { use super::env_pass_validator; |