aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-09-29 19:18:56 +0200
committerDaniel Mueller <deso@posteo.net>2021-01-10 21:07:25 -0800
commitb619f78f45fdd3ecbcaa2e30134866e8ab694d6d (patch)
tree5131ea50c486ff06cb9740b26729414785b442dc
parent9585cfd98beb2156f75d15c22c694cb34a29f6ec (diff)
downloadnitrocli-b619f78f45fdd3ecbcaa2e30134866e8ab694d6d.tar.gz
nitrocli-b619f78f45fdd3ecbcaa2e30134866e8ab694d6d.tar.bz2
Rename numlock, capslock, scrollock options
This patch renames the options for the config set command: --numlock ==> --num-lock --capslock ==> --caps-lock --scrolllock ==> --scroll-lock --no-numlock ==> --no-num-lock --no-capslock ==> --no-caps-lock --no-scrolllock ==> --no-scroll-lock The original naming was based on a typo in nitrokey-rs (scrollock vs. scrolllock). Also, the typical spelling for the keys is Num Lock, Caps Lock and Scroll Lock, so using a hyphen is a more natural.
-rw-r--r--CHANGELOG.md2
-rw-r--r--doc/nitrocli.120
-rw-r--r--doc/nitrocli.1.pdfbin43549 -> 43583 bytes
-rw-r--r--src/args.rs30
-rw-r--r--src/commands.rs25
-rw-r--r--src/tests/config.rs16
6 files changed, 48 insertions, 45 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc268a2..d6c7696 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ Unreleased
- Added the `termion` dependency in version `1.5.5`
- Added SD card usage information to the output of the `status` command for
Storage devices
+- Renamed the `--{no-,}{numlock,capslock,scrollock}` options of the `config
+ set` command to `--{no-,}{num-lock,caps-lock,scroll-lock}`
- Bumped `nitrokey` dependency to `0.8.0`
diff --git a/doc/nitrocli.1 b/doc/nitrocli.1
index fc089ad..bdbfb2d 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/doc/nitrocli.1.pdf b/doc/nitrocli.1.pdf
index f8b62e5..00bb14e 100644
--- a/doc/nitrocli.1.pdf
+++ b/doc/nitrocli.1.pdf
Binary files differ
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 eba9276..092b006 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,13 @@ 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 +693,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)
$"#,
)