diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-04-27 09:32:45 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-05-11 10:48:44 +0200 |
commit | 60f0712a95d7cdf46554a87893fb71354f2631c5 (patch) | |
tree | b5176d6b9366593feac28b5f1c81afc55a3fc889 /src/cli.rs | |
parent | 7d71ae3bf605a0c5ed38c8dfd9dc6abafbeae315 (diff) |
Add subcommand: endpoint containers stop
Implementation of the "endpoint containers stop" subcommand.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -994,6 +994,42 @@ pub fn cli<'a>() -> App<'a> { .conflicts_with("older_than") ) ) + .subcommand(App::new("stop") + .version(crate_version!()) + .about("Stop running containers") + .arg(Arg::new("older_than") + .required(false) + .multiple(false) + .long("older-than") + .takes_value(true) + .value_name("DATE") + .about("Stop 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("Stop only containers that are newer than DATE") + .validator(parse_date_from_string) + .conflicts_with("older_than") + ) + + .arg(Arg::new("timeout") + .required(false) + .multiple(false) + .long("timeout") + .short('t') + .takes_value(true) + .value_name("TIMEOUT") + .about("Timeout in seconds") + .validator(parse_u64) + ) + ) .subcommand(App::new("list") .version(crate_version!()) .about("List the containers and stats about them") @@ -1230,6 +1266,10 @@ fn parse_usize(s: &str) -> std::result::Result<(), String> { usize::from_str(s) .map_err(|e| e.to_string()).map(|_| ()) } +fn parse_u64(s: &str) -> std::result::Result<(), String> { + u64::from_str(s).map_err(|e| e.to_string()).map(|_| ()) +} + #[cfg(test)] mod tests { use super::env_pass_validator; |