Skip to content

Commit

Permalink
Add scaffolding for the list command
Browse files Browse the repository at this point in the history
This patch adds the basic scaffolding for the list command which will
list all attached Nitrokey devices.
  • Loading branch information
robinkrahl authored and d-e-s-o committed Apr 4, 2020
1 parent 5462849 commit 95b5d04
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -263,6 +265,13 @@ struct HiddenCreateArgs {
end: u8,
}

#[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)]
Expand Down
5 changes: 5 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down

0 comments on commit 95b5d04

Please sign in to comment.