diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-04-28 14:06:30 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-05-11 10:15:50 +0200 |
commit | aa3b529f3f23275ff14a222401af80d63e293697 (patch) | |
tree | 00deddcd6f603026cc34304aad4c8e7552e5ec17 /src/cli.rs | |
parent | 2c0c0eb515aa4d3d3de1ab47351733ba59c983f1 (diff) |
Add subcommand to get top output of containers
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -9,6 +9,7 @@ // use std::path::PathBuf; +use std::str::FromStr; use clap::crate_authors; use clap::crate_version; @@ -1043,6 +1044,26 @@ pub fn cli<'a>() -> App<'a> { .conflicts_with("older_than") ) ) + .subcommand(App::new("top") + .version(crate_version!()) + .about("List the processes of all containers") + .arg(Arg::new("csv") + .required(false) + .multiple(false) + .long("csv") + .takes_value(false) + .about("List top output as CSV") + ) + .arg(Arg::new("limit") + .required(false) + .multiple(false) + .long("limit") + .takes_value(true) + .value_name("LIMIT") + .about("Only list LIMIT processes for each container") + .validator(parse_usize) + ) + ) ) .subcommand(App::new("container") .version(crate_version!()) @@ -1205,6 +1226,10 @@ fn parse_date_from_string(s: &str) -> std::result::Result<(), String> { humantime::parse_rfc3339_weak(s).map_err(|e| e.to_string()).map(|_| ()) } +fn parse_usize(s: &str) -> std::result::Result<(), String> { + usize::from_str(s) .map_err(|e| e.to_string()).map(|_| ()) +} + #[cfg(test)] mod tests { use super::env_pass_validator; |