summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-04-27 09:32:45 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-05-11 10:48:44 +0200
commit60f0712a95d7cdf46554a87893fb71354f2631c5 (patch)
treeb5176d6b9366593feac28b5f1c81afc55a3fc889 /src/cli.rs
parent7d71ae3bf605a0c5ed38c8dfd9dc6abafbeae315 (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.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 94187da..47ef88f 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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;