aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/args.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-12-27 17:49:14 +0100
committerDaniel Mueller <deso@posteo.net>2019-01-07 18:13:46 -0800
commit0c679b30ef04de8bc556ce33b305d3ccf740a970 (patch)
tree2e47aa26e71ca65cd6d6e9ad6d6b7e11a5fc82e5 /nitrocli/src/args.rs
parent6a69bbf736966c493cead716026db92c5b44962a (diff)
downloadnitrocli-0c679b30ef04de8bc556ce33b305d3ccf740a970.tar.gz
nitrocli-0c679b30ef04de8bc556ce33b305d3ccf740a970.tar.bz2
Implement the pws status subcommand
This patch implements the pws status command that can be used to print status information for the slots in the password safe.
Diffstat (limited to 'nitrocli/src/args.rs')
-rw-r--r--nitrocli/src/args.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index 28ccb1f..4cf6258 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -329,6 +329,7 @@ enum PwsCommand {
Clear,
Get,
Set,
+ Status,
}
impl PwsCommand {
@@ -337,6 +338,7 @@ impl PwsCommand {
PwsCommand::Clear => pws_clear(args),
PwsCommand::Get => pws_get(args),
PwsCommand::Set => pws_set(args),
+ PwsCommand::Status => pws_status(args),
}
}
}
@@ -350,6 +352,7 @@ impl fmt::Display for PwsCommand {
PwsCommand::Clear => "clear",
PwsCommand::Get => "get",
PwsCommand::Set => "set",
+ PwsCommand::Status => "status",
}
)
}
@@ -363,6 +366,7 @@ impl str::FromStr for PwsCommand {
"clear" => Ok(PwsCommand::Clear),
"get" => Ok(PwsCommand::Get),
"set" => Ok(PwsCommand::Set),
+ "status" => Ok(PwsCommand::Status),
_ => Err(()),
}
}
@@ -804,7 +808,7 @@ fn pws(args: Vec<String>) -> Result<()> {
let _ = parser.refer(&mut subcommand).required().add_argument(
"subcommand",
argparse::Store,
- "The subcommand to execute (clear|get|set)",
+ "The subcommand to execute (clear|get|set|status)",
);
let _ = parser.refer(&mut subargs).add_argument(
"arguments",
@@ -909,6 +913,22 @@ fn pws_clear(args: Vec<String>) -> Result<()> {
commands::pws_clear(slot)
}
+/// Print the status of the PWS slots.
+fn pws_status(args: Vec<String>) -> Result<()> {
+ let mut all = false;
+ let mut parser = argparse::ArgumentParser::new();
+ parser.set_description("Prints the status of the PWS slots");
+ let _ = parser.refer(&mut all).add_option(
+ &["-a", "--all"],
+ argparse::StoreTrue,
+ "Show slots that are not programmed",
+ );
+ parse(&parser, args)?;
+ drop(parser);
+
+ commands::pws_status(all)
+}
+
/// Parse the command-line arguments and return the selected command and
/// the remaining arguments for the command.
fn parse_arguments(args: Vec<String>) -> Result<(Command, Vec<String>)> {