From fb235d0cf88687eb214b3ec7cb5fab596609d2b6 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 28 Dec 2018 11:01:08 -0800 Subject: 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. --- nitrocli/src/args.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'nitrocli/src/args.rs') 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) -> Result<()> /// Inquire the status of the nitrokey. fn status(args: Vec) -> 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) -> 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) -> Result<()> { commands::storage_close() } +/// Print the status of the nitrokey's storage. +fn storage_status(args: Vec) -> 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) -> Result<()> { let mut parser = argparse::ArgumentParser::new(); -- cgit v1.2.1