diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-19 21:23:08 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-19 21:23:08 -0400 |
commit | bc543e4f26d3e29fe88a61457a924ab6ab238535 (patch) | |
tree | b2acc53d5a9be23efb0cf2e26afa8132f4351d7f /src/bin/rbw/main.rs | |
parent | ce00f07e6cf16e41c1b658ff3161d5e18a62da3b (diff) | |
download | rbw-bc543e4f26d3e29fe88a61457a924ab6ab238535.tar.gz rbw-bc543e4f26d3e29fe88a61457a924ab6ab238535.zip |
allow listing various different fields
Diffstat (limited to 'src/bin/rbw/main.rs')
-rw-r--r-- | src/bin/rbw/main.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index 051a7bc..c95e319 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -26,7 +26,15 @@ fn main() { .subcommand(clap::SubCommand::with_name("login")) .subcommand(clap::SubCommand::with_name("unlock")) .subcommand(clap::SubCommand::with_name("sync")) - .subcommand(clap::SubCommand::with_name("list")) + .subcommand( + clap::SubCommand::with_name("list").arg( + clap::Arg::with_name("fields") + .long("fields") + .takes_value(true) + .use_delimiter(true) + .multiple(true), + ), + ) .subcommand( clap::SubCommand::with_name("get") .arg(clap::Arg::with_name("name").required(true)) @@ -115,7 +123,13 @@ fn main() { ("login", Some(_)) => commands::login().context("login"), ("unlock", Some(_)) => commands::unlock().context("unlock"), ("sync", Some(_)) => commands::sync().context("sync"), - ("list", Some(_)) => commands::list().context("list"), + ("list", Some(smatches)) => commands::list( + &smatches + .values_of("fields") + .map(|it| it.collect()) + .unwrap_or_else(|| vec!["name"]), + ) + .context("list"), // this unwrap is safe because name is marked .required(true) ("get", Some(smatches)) => commands::get( smatches.value_of("name").unwrap(), |