aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--doc/nitrocli.120
-rw-r--r--src/args.rs30
-rw-r--r--src/commands.rs24
-rw-r--r--src/tests/config.rs16
5 files changed, 47 insertions, 45 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63d300c..f6718e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,8 @@ Unreleased
- Bumped `structopt` dependency to `0.3.17`
- Bumped `nitrokey` dependency to `0.8.0`
- Added the `librem` device model
+ - Renamed the `--{no-,}{numlock,capslock,scrollock}` options of the `config
+ set` command to `--{no-,}{num-lock,caps-lock,scroll-lock}`
0.3.4
diff --git a/doc/nitrocli.1 b/doc/nitrocli.1
index 12ced4b..047a9df 100644
--- a/doc/nitrocli.1
+++ b/doc/nitrocli.1
@@ -217,26 +217,26 @@ List all OTP slots.
If \fB\-\-all\fR is not set, empty slots are ignored.
.SS Configuration
-Nitrokey devices have four configuration settings: the numlock, capslock and
-scrollock keys can be mapped to an HOTP slot, and OTP generation can be set to
-require the user PIN.
+Nitrokey devices have four configuration settings: the Num Lock, Caps Lock and
+Scroll Lock keys can be mapped to an HOTP slot, and OTP generation can be set
+to require the user PIN.
.TP
\fBnitrocli config get\fR
Print the current Nitrokey configuration.
.TP
\fBnitrocli config set \fR\
-[[\fB\-n\fR|\fB\-\-numlock \fIslot\fR] | [\fB\-N\fR|\fB\-\-no\-numlock\fR]] \
-[[\fB\-c\fR|\fB\-\-capslock \fIslot\fR] | [\fB\-C\fR|\fB\-\-no\-capslock\fR]] \
-[[\fB\-s\fR|\fB\-\-scrollock \fIslot\fR] | [\fB\-S\fR|\fB\-\-no\-scrollock\fR]] \
+[[\fB\-n\fR|\fB\-\-num-lock \fIslot\fR] | [\fB\-N\fR|\fB\-\-no\-num-lock\fR]] \
+[[\fB\-c\fR|\fB\-\-caps-lock \fIslot\fR] | [\fB\-C\fR|\fB\-\-no\-caps-lock\fR]] \
+[[\fB\-s\fR|\fB\-\-scroll-lock \fIslot\fR] | [\fB\-S\fR|\fB\-\-no\-scroll-lock\fR]] \
[[\fB\-o\fR|\fB\-\-otp\-pin\fR] | [\fB\-O\fR|\fB\-\-no\-otp\-pin\fR]]
Update the Nitrokey configuration.
This command requires the admin PIN.
-With the \fB\-\-numlock\fR, \fB\-\-capslock\fR and \fB\-\-scrollock\fR options,
-the respective bindings can be set.
+With the \fB\-\-num-lock\fR, \fB\-\-caps-lock\fR and \fB\-\-scroll-lock\fR
+options, the respective bindings can be set.
\fIslot\fR is the number of the HOTP slot to bind the key to.
-If \fB\-\-no\-numlock\fR, \fB\-\-no\-capslock\fR or \fB\-\-no\-scrollock\fR is
-set, the respective binding is disabled.
+If \fB\-\-no\-num-lock\fR, \fB\-\-no\-caps-lock\fR or \fB\-\-no\-scroll-lock\fR
+is set, the respective binding is disabled.
The two corresponding options are mutually exclusive.
If \fB\-\-otp\-pin\fR is set, the user PIN will be required to generate one-time
diff --git a/src/args.rs b/src/args.rs
index a38ca6a..6cf37c8 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -125,24 +125,24 @@ Command! {ConfigCommand, [
#[derive(Debug, PartialEq, structopt::StructOpt)]
pub struct ConfigSetArgs {
- /// Sets the numlock option to the given HOTP slot
+ /// Sets the Num Lock option to the given HOTP slot
#[structopt(short = "n", long)]
- pub numlock: Option<u8>,
- /// Unsets the numlock option
- #[structopt(short = "N", long, conflicts_with("numlock"))]
- pub no_numlock: bool,
- /// Sets the capslock option to the given HOTP slot
+ pub num_lock: Option<u8>,
+ /// Unsets the Num Lock option
+ #[structopt(short = "N", long, conflicts_with("num-lock"))]
+ pub no_num_lock: bool,
+ /// Sets the Cap Lock option to the given HOTP slot
#[structopt(short = "c", long)]
- pub capslock: Option<u8>,
- /// Unsets the capslock option
- #[structopt(short = "C", long, conflicts_with("capslock"))]
- pub no_capslock: bool,
- /// Sets the scrollock option to the given HOTP slot
+ pub caps_lock: Option<u8>,
+ /// Unsets the Caps Lock option
+ #[structopt(short = "C", long, conflicts_with("caps-lock"))]
+ pub no_caps_lock: bool,
+ /// Sets the Scroll Lock option to the given HOTP slot
#[structopt(short = "s", long)]
- pub scrollock: Option<u8>,
- /// Unsets the scrollock option
- #[structopt(short = "S", long, conflicts_with("scrollock"))]
- pub no_scrollock: bool,
+ pub scroll_lock: Option<u8>,
+ /// Unsets the Scroll Lock option
+ #[structopt(short = "S", long, conflicts_with("scroll-lock"))]
+ pub no_scroll_lock: bool,
/// Requires the user PIN to generate one-time passwords
#[structopt(short = "o", long)]
pub otp_pin: bool,
diff --git a/src/commands.rs b/src/commands.rs
index c5a3b11..29f3b08 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -657,9 +657,9 @@ pub fn config_get(ctx: &mut Context<'_>) -> anyhow::Result<()> {
println!(
ctx,
r#"Config:
- numlock binding: {nl}
- capslock binding: {cl}
- scrollock binding: {sl}
+ num lock binding: {nl}
+ caps lock binding: {cl}
+ scroll lock binding: {sl}
require user PIN for OTP: {otp}"#,
nl = format_option(config.num_lock),
cl = format_option(config.caps_lock),
@@ -672,12 +672,12 @@ pub fn config_get(ctx: &mut Context<'_>) -> anyhow::Result<()> {
/// Write the Nitrokey configuration.
pub fn config_set(ctx: &mut Context<'_>, args: args::ConfigSetArgs) -> anyhow::Result<()> {
- let numlock = args::ConfigOption::try_from(args.no_numlock, args.numlock, "numlock")
- .context("Failed to apply numlock configuration")?;
- let capslock = args::ConfigOption::try_from(args.no_capslock, args.capslock, "capslock")
- .context("Failed to apply capslock configuration")?;
- let scrollock = args::ConfigOption::try_from(args.no_scrollock, args.scrollock, "scrollock")
- .context("Failed to apply scrollock configuration")?;
+ let num_lock = args::ConfigOption::try_from(args.no_num_lock, args.num_lock, "numlock")
+ .context("Failed to apply num lock configuration")?;
+ let caps_lock = args::ConfigOption::try_from(args.no_caps_lock, args.caps_lock, "capslock")
+ .context("Failed to apply caps lock configuration")?;
+ let scroll_lock = args::ConfigOption::try_from(args.no_scroll_lock, args.scroll_lock, "scrollock")
+ .context("Failed to apply scroll lock configuration")?;
let otp_pin = if args.otp_pin {
Some(true)
} else if args.no_otp_pin {
@@ -692,9 +692,9 @@ pub fn config_set(ctx: &mut Context<'_>, args: args::ConfigSetArgs) -> anyhow::R
.get_config()
.context("Failed to get current configuration")?;
let config = nitrokey::Config {
- num_lock: numlock.or(config.num_lock),
- caps_lock: capslock.or(config.caps_lock),
- scroll_lock: scrollock.or(config.scroll_lock),
+ num_lock: num_lock.or(config.num_lock),
+ caps_lock: caps_lock.or(config.caps_lock),
+ scroll_lock: scroll_lock.or(config.scroll_lock),
user_password: otp_pin.unwrap_or(config.user_password),
};
device
diff --git a/src/tests/config.rs b/src/tests/config.rs
index babd32c..b3d27de 100644
--- a/src/tests/config.rs
+++ b/src/tests/config.rs
@@ -26,9 +26,9 @@ fn mutually_exclusive_set_options() {
fn get(model: nitrokey::Model) -> anyhow::Result<()> {
let re = regex::Regex::new(
r#"^Config:
- numlock binding: (not set|\d+)
- capslock binding: (not set|\d+)
- scrollock binding: (not set|\d+)
+ num lock binding: (not set|\d+)
+ caps lock binding: (not set|\d+)
+ scroll lock binding: (not set|\d+)
require user PIN for OTP: (true|false)
$"#,
)
@@ -44,12 +44,12 @@ $"#,
fn set_wrong_usage(model: nitrokey::Model) {
let err = Nitrocli::new()
.model(model)
- .handle(&["config", "set", "--numlock", "2", "-N"])
+ .handle(&["config", "set", "--num-lock", "2", "-N"])
.unwrap_err()
.to_string();
assert!(
- err.contains("The argument '--numlock <numlock>' cannot be used with '--no-numlock'"),
+ err.contains("The argument '--num-lock <num-lock>' cannot be used with '--no-num-lock'"),
err,
);
}
@@ -61,9 +61,9 @@ fn set_get(model: nitrokey::Model) -> anyhow::Result<()> {
let re = regex::Regex::new(
r#"^Config:
- numlock binding: not set
- capslock binding: 0
- scrollock binding: 1
+ num lock binding: not set
+ caps lock binding: 0
+ scroll lock binding: 1
require user PIN for OTP: (true|false)
$"#,
)