aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/args.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2018-12-28 11:01:08 -0800
committerDaniel Mueller <deso@posteo.net>2018-12-28 11:01:08 -0800
commitfb235d0cf88687eb214b3ec7cb5fab596609d2b6 (patch)
treedcc3e8f6dbeea60a42685c9030100e22f4dcc7b1 /nitrocli/src/args.rs
parent8f8f6b11f353f12b8a4018b8bc25aa02bc914955 (diff)
downloadnitrocli-fb235d0cf88687eb214b3ec7cb5fab596609d2b6.tar.gz
nitrocli-fb235d0cf88687eb214b3ec7cb5fab596609d2b6.tar.bz2
Move printing of storage related status into 'storage status' sub-command
The 'status' command has traditionally printed information about the connected Nitrokey and that included storage specific data if the device present is a Nitrokey Storage. Given that we have a root-level 'storage' command it arguably makes sense to move the printing of the storage related status information into a 'status' sub-command of the said command, which makes the output more predictable.
Diffstat (limited to 'nitrocli/src/args.rs')
-rw-r--r--nitrocli/src/args.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index e7e7717..e533c82 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -286,7 +286,7 @@ fn parse(parser: &argparse::ArgumentParser<'_>, args: Vec<String>) -> Result<()>
/// Inquire the status of the nitrokey.
fn status(args: Vec<String>) -> Result<()> {
let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Print the status of the connected Nitrokey device");
+ parser.set_description("Prints the status of the connected Nitrokey device");
parse(&parser, args)?;
commands::status()
@@ -296,6 +296,7 @@ fn status(args: Vec<String>) -> Result<()> {
enum StorageCommand {
Close,
Open,
+ Status,
}
impl StorageCommand {
@@ -303,6 +304,7 @@ impl StorageCommand {
match *self {
StorageCommand::Close => storage_close(args),
StorageCommand::Open => storage_open(args),
+ StorageCommand::Status => storage_status(args),
}
}
}
@@ -315,6 +317,7 @@ impl fmt::Display for StorageCommand {
match *self {
StorageCommand::Close => "close",
StorageCommand::Open => "open",
+ StorageCommand::Status => "status",
}
)
}
@@ -327,6 +330,7 @@ impl str::FromStr for StorageCommand {
match s {
"close" => Ok(StorageCommand::Close),
"open" => Ok(StorageCommand::Open),
+ "status" => Ok(StorageCommand::Status),
_ => Err(()),
}
}
@@ -374,6 +378,15 @@ fn storage_close(args: Vec<String>) -> Result<()> {
commands::storage_close()
}
+/// Print the status of the nitrokey's storage.
+fn storage_status(args: Vec<String>) -> Result<()> {
+ let mut parser = argparse::ArgumentParser::new();
+ parser.set_description("Prints the status of the Nitrokey's storage");
+ parse(&parser, args)?;
+
+ commands::storage_status()
+}
+
/// Clear the PIN as cached by various other commands.
fn clear(args: Vec<String>) -> Result<()> {
let mut parser = argparse::ArgumentParser::new();