summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-14 19:32:28 +0100
committerDaniel Mueller <deso@posteo.net>2020-01-14 19:32:28 +0100
commita60b03f58437e358b24a96a4e6b2a2c11d277e6b (patch)
tree6f4a9d9bbcfcb62ef20e232addc713974f4b7f19
parent1df484fd699f88b6d7e23c09464294a7c26c7e00 (diff)
downloadnitrocli-a60b03f58437e358b24a96a4e6b2a2c11d277e6b.tar.gz
nitrocli-a60b03f58437e358b24a96a4e6b2a2c11d277e6b.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--CHANGELOG.md1
-rw-r--r--README.md1
-rw-r--r--src/args.rs9
-rw-r--r--src/commands.rs5
4 files changed, 16 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9eeb9f3..8da31f5 100644
--- a/CHANGELOG.md
+++ b/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/README.md b/README.md
index f76216f..6672914 100644
--- a/README.md
+++ b/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/src/args.rs b/src/args.rs
index aeedfe6..91bddc5 100644
--- a/src/args.rs
+++ b/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/src/commands.rs b/src/commands.rs
index cc57786..3bc7300 100644
--- a/src/commands.rs
+++ b/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| {