aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-08 11:59:08 +0000
committerDaniel Mueller <deso@posteo.net>2020-01-08 11:59:08 +0000
commit6be66131cb6f76c1d8120847bb462c4abd5d5077 (patch)
treed876d6a69d49b4164e4ee035d8cc27d0d94bd8e7
parent32ce42fb8cba93aef8d3ced05e47497d0b40d732 (diff)
downloadnitrocli-6be66131cb6f76c1d8120847bb462c4abd5d5077.tar.gz
nitrocli-6be66131cb6f76c1d8120847bb462c4abd5d5077.tar.bz2
Remove empty Args structs for simple (sub-)commands
Since we updated the Command! macro to also allow enum variants without fields, we no longer need the empty *Args structs for commands or subcommands without arguments or options.
-rw-r--r--src/args.rs50
1 files changed, 10 insertions, 40 deletions
diff --git a/src/args.rs b/src/args.rs
index fb734b9..ec35f06 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -118,7 +118,7 @@ Command! {Command, [
/// Interacts with the device's hidden volume
Hidden(HiddenArgs) => |ctx, args: HiddenArgs| args.subcmd.execute(ctx),
/// Locks the connected Nitrokey device
- Lock(LockArgs) => |ctx, _| commands::lock(ctx),
+ Lock => commands::lock,
/// Accesses one-time passwords
Otp(OtpArgs) => |ctx, args: OtpArgs| args.subcmd.execute(ctx),
/// Manages the Nitrokey PINs
@@ -126,9 +126,9 @@ Command! {Command, [
/// Accesses the password safe
Pws(PwsArgs) => |ctx, args: PwsArgs| args.subcmd.execute(ctx),
/// Performs a factory reset
- Reset(ResetArgs) => |ctx, _| commands::reset(ctx),
+ Reset => commands::reset,
/// Prints the status of the connected Nitrokey device
- Status(StatusArgs) => |ctx, _| commands::status(ctx),
+ Status => commands::status,
/// Interacts with the device's unencrypted volume
Unencrypted(UnencryptedArgs) => |ctx, args: UnencryptedArgs| args.subcmd.execute(ctx),
]}
@@ -141,15 +141,12 @@ pub struct ConfigArgs {
Command! {ConfigCommand, [
/// Prints the Nitrokey configuration
- Get(ConfigGetArgs) => |ctx, _| commands::config_get(ctx),
+ Get => commands::config_get,
/// Changes the Nitrokey configuration
Set(ConfigSetArgs) => config_set,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct ConfigGetArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct ConfigSetArgs {
/// Sets the numlock option to the given HOTP slot
#[structopt(short = "n", long)]
@@ -234,18 +231,12 @@ pub struct EncryptedArgs {
Command! {EncryptedCommand, [
/// Closes the encrypted volume on a Nitrokey Storage
- Close(EncryptedCloseArgs) => |ctx, _| commands::encrypted_close(ctx),
+ Close => commands::encrypted_close,
/// Opens the encrypted volume on a Nitrokey Storage
- Open(EncryptedOpenArgs) => |ctx, _| commands::encrypted_open(ctx),
+ Open => commands::encrypted_open,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct EncryptedCloseArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct EncryptedOpenArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct HiddenArgs {
#[structopt(subcommand)]
subcmd: HiddenCommand,
@@ -253,19 +244,16 @@ pub struct HiddenArgs {
Command! {HiddenCommand, [
/// Closes the hidden volume on a Nitrokey Storage
- Close(HiddenCloseArgs) => |ctx, _| commands::hidden_close(ctx),
+ Close => commands::hidden_close,
/// Creates a hidden volume on a Nitrokey Storage
Create(HiddenCreateArgs) => |ctx, args: HiddenCreateArgs| {
commands::hidden_create(ctx, args.slot, args.start, args.end)
},
/// Opens the hidden volume on a Nitrokey Storage
- Open(HiddenOpenArgs) => |ctx, _| commands::hidden_open(ctx),
+ Open => commands::hidden_open,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct HiddenCloseArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct HiddenCreateArgs {
/// The hidden volume slot to use
slot: u8,
@@ -276,12 +264,6 @@ pub struct HiddenCreateArgs {
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct HiddenOpenArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct LockArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct OtpArgs {
#[structopt(subcommand)]
subcmd: OtpCommand,
@@ -408,17 +390,14 @@ pub struct PinArgs {
Command! {PinCommand, [
/// Clears the cached PINs
- Clear(PinClearArgs) => |ctx, _| commands::pin_clear(ctx),
+ Clear => commands::pin_clear,
/// Changes a PIN
Set(PinSetArgs) => |ctx, args: PinSetArgs| commands::pin_set(ctx, args.pintype),
/// Unblocks and resets the user PIN
- Unblock(PinUnblockArgs) => |ctx, _| commands::pin_unblock(ctx),
+ Unblock => commands::pin_unblock,
]}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct PinClearArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct PinSetArgs {
/// The PIN type to change
#[structopt(name = "type", possible_values = &pinentry::PinType::all_str())]
@@ -426,9 +405,6 @@ pub struct PinSetArgs {
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct PinUnblockArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct PwsArgs {
#[structopt(subcommand)]
subcmd: PwsCommand,
@@ -493,12 +469,6 @@ pub struct PwsStatusArgs {
}
#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct ResetArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
-pub struct StatusArgs {}
-
-#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct UnencryptedArgs {
#[structopt(subcommand)]
subcmd: UnencryptedCommand,