diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-09-05 13:18:28 +0200 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-09-05 13:18:28 +0200 |
commit | 9dca5be8b182773a7b7eb23b47296d403540ead4 (patch) | |
tree | dbcd27be5fbdf3ab704a8f9410624e7085234340 /src/args.rs | |
parent | 561ee11c37a96ae043c19fcf056576d9892b36a5 (diff) | |
download | nitrocli-9dca5be8b182773a7b7eb23b47296d403540ead4.tar.gz nitrocli-9dca5be8b182773a7b7eb23b47296d403540ead4.tar.bz2 |
Use dedicated types for output
Previously, we just printed nitrocli’s output to the stdout stream using
format macros. To make it possible to support multiple output formats,
this patch introduces the output module with dedicated types for the
data that is printed to stdout:
- Value: A single value, e. g. an OTP code or the configuration data.
- Table: A list of objects, rendered as a table, e. g. the list of OTP
slots.
With this patch, we also drop the --quiet option for the pws get
command. It was intended to make it easier to parse the output of the
command. But as we will add better output formats for parsing, we no
longer need this option.
TODO: update changelog
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/args.rs b/src/args.rs index 3052afa..f54025e 100644 --- a/src/args.rs +++ b/src/args.rs @@ -37,6 +37,15 @@ impl DeviceModel { } } +impl From<nitrokey::Model> for DeviceModel { + fn from(model: nitrokey::Model) -> DeviceModel { + match model { + nitrokey::Model::Pro => DeviceModel::Pro, + nitrokey::Model::Storage => DeviceModel::Storage, + } + } +} + impl From<DeviceModel> for nitrokey::Model { fn from(model: DeviceModel) -> nitrokey::Model { match model { @@ -357,7 +366,7 @@ Command! {PwsCommand, [ Clear(PwsClearArgs) => |ctx, args: PwsClearArgs| crate::commands::pws_clear(ctx, args.slot), /// Reads a password safe slot Get(PwsGetArgs) => |ctx, args: PwsGetArgs| { - crate::commands::pws_get(ctx, args.slot, args.name, args.login, args.password, args.quiet) + crate::commands::pws_get(ctx, args.slot, args.name, args.login, args.password) }, /// Writes a password safe slot Set(PwsSetArgs) => |ctx, args: PwsSetArgs| { @@ -384,9 +393,6 @@ pub struct PwsGetArgs { /// Shows the password stored on the slot #[structopt(short, long)] pub password: bool, - /// Prints the stored data without description - #[structopt(short, long)] - pub quiet: bool, /// The PWS slot to read pub slot: u8, } |