diff options
| author | Robin Krahl <robin.krahl@ireas.org> | 2020-01-14 19:32:28 +0100 | 
|---|---|---|
| committer | Daniel Mueller <deso@posteo.net> | 2020-01-15 12:08:15 -0800 | 
| commit | a9af2d4295c1c0467ffd65a264559c7b4fe38d11 (patch) | |
| tree | 3691ff6520e98e27b133d990ccfe9a3aad59628a | |
| parent | 1e07212370806f3ea4ff7a6f66e5716b60ab1f77 (diff) | |
| download | nitrocli-a9af2d4295c1c0467ffd65a264559c7b4fe38d11.tar.gz nitrocli-a9af2d4295c1c0467ffd65a264559c7b4fe38d11.tar.bz2 | |
Add scaffolding for the list command
This patch adds the basic scaffolding for the list command which will
list all attached Nitrokey devices.
| -rw-r--r-- | nitrocli/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | nitrocli/README.md | 1 | ||||
| -rw-r--r-- | nitrocli/src/args.rs | 9 | ||||
| -rw-r--r-- | nitrocli/src/commands.rs | 5 | 
4 files changed, 16 insertions, 0 deletions
| diff --git a/nitrocli/CHANGELOG.md b/nitrocli/CHANGELOG.md index 331e60b..53847e5 100644 --- a/nitrocli/CHANGELOG.md +++ b/nitrocli/CHANGELOG.md @@ -1,5 +1,6 @@  Unreleased  ---------- +- Added the `list` command that lists all attached Nitrokey devices  - Reworked argument handling:    - Added `structopt` dependency in version `0.3.7`    - Replaced `argparse` with `structopt` diff --git a/nitrocli/README.md b/nitrocli/README.md index 0f01ac5..a1833ac 100644 --- a/nitrocli/README.md +++ b/nitrocli/README.md @@ -13,6 +13,7 @@ Storage][nitrokey-storage] devices.  The following commands are currently supported: +- list: List all attached Nitrokey devices.  - status: Report status information about the Nitrokey.  - lock: Lock the Nitrokey.  - config: Access the Nitrokey's configuration diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs index aeedfe6..91bddc5 100644 --- a/nitrocli/src/args.rs +++ b/nitrocli/src/args.rs @@ -117,6 +117,8 @@ Command! {Command, [    Encrypted(EncryptedArgs) => |ctx, args: EncryptedArgs| args.subcmd.execute(ctx),    /// Interacts with the device's hidden volume    Hidden(HiddenArgs) => |ctx, args: HiddenArgs| args.subcmd.execute(ctx), +  /// Lists the attached Nitrokey devices +  List(ListArgs) => |ctx, args: ListArgs| commands::list(ctx, args.no_connect),    /// Locks the connected Nitrokey device    Lock => commands::lock,    /// Accesses one-time passwords @@ -264,6 +266,13 @@ struct HiddenCreateArgs {  }  #[derive(Debug, PartialEq, structopt::StructOpt)] +struct ListArgs { +  /// Only print the information that is available without connecting to a device +  #[structopt(short, long)] +  no_connect: bool, +} + +#[derive(Debug, PartialEq, structopt::StructOpt)]  struct OtpArgs {    #[structopt(subcommand)]    subcmd: OtpCommand, diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index cc57786..3bc7300 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -376,6 +376,11 @@ pub fn status(ctx: &mut args::ExecCtx<'_>) -> Result<()> {    })  } +/// List the attached Nitrokey devices. +pub fn list(_ctx: &mut args::ExecCtx<'_>, _no_connect: bool) -> Result<()> { +  unimplemented!(); +} +  /// Perform a factory reset.  pub fn reset(ctx: &mut args::ExecCtx<'_>) -> Result<()> {    with_device(ctx, |ctx, mut device| { | 
