summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nitrocli/src/args.rs9
-rw-r--r--nitrocli/src/commands.rs8
2 files changed, 14 insertions, 3 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index ae09c07..b83c495 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -108,6 +108,15 @@ Enum! {DeviceModel, [
Storage => "storage",
]}
+impl DeviceModel {
+ pub fn as_user_facing_str(&self) -> &str {
+ match self {
+ DeviceModel::Pro => "Pro",
+ DeviceModel::Storage => "Storage",
+ }
+ }
+}
+
impl From<DeviceModel> for nitrokey::Model {
fn from(model: DeviceModel) -> nitrokey::Model {
match model {
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
index 208a0ec..583870b 100644
--- a/nitrocli/src/commands.rs
+++ b/nitrocli/src/commands.rs
@@ -62,10 +62,12 @@ fn get_device(ctx: &mut args::ExecCtx<'_>) -> Result<nitrokey::DeviceWrapper> {
set_log_level(ctx);
match ctx.model {
- Some(model) => nitrokey::connect_model(model.into()),
- None => nitrokey::connect(),
+ Some(model) => nitrokey::connect_model(model.into()).map_err(|_| {
+ let error = format!("Nitrokey {} device not found", model.as_user_facing_str());
+ Error::Error(error)
+ }),
+ None => nitrokey::connect().map_err(|_| Error::from("Nitrokey device not found")),
}
- .map_err(|_| Error::from("Nitrokey device not found"))
}
/// Connect to a Nitrokey Storage device and return it.