summaryrefslogtreecommitdiff
path: root/src/commands.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-23 10:54:09 +0100
committerDaniel Mueller <deso@posteo.net>2021-01-10 10:03:09 -0800
commit9d3c50ca3f9ff0bf12b1b25344959ed333ffbdee (patch)
treee1887917dc1eb94a23642ebe26b2f6c02b705188 /src/commands.rs
parent887f3cb9aab12b390ae9efe09c1ff7f972e51c35 (diff)
downloadnitrocli-9d3c50ca3f9ff0bf12b1b25344959ed333ffbdee.tar.gz
nitrocli-9d3c50ca3f9ff0bf12b1b25344959ed333ffbdee.tar.bz2
Implement configuration handling
This patch implements basic configuration handling that reads a configuration file and stores the parsed data in the ExecCtx and RunCtx structs. It supports three configuration items: - model (previously only --model) - no_cache (previously only NITROCLI_NO_CACHE) - verbosity (previously only --verbose)
Diffstat (limited to 'src/commands.rs')
-rw-r--r--src/commands.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/commands.rs b/src/commands.rs
index 1d59af5..090d532 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -39,7 +39,7 @@ use crate::ExecCtx;
/// Set `libnitrokey`'s log level based on the execution context's verbosity.
fn set_log_level(ctx: &mut ExecCtx<'_>) {
- let log_lvl = match ctx.verbosity {
+ let log_lvl = match ctx.config.verbosity {
// The error log level is what libnitrokey uses by default. As such,
// there is no harm in us setting that as well when the user did not
// ask for higher verbosity.
@@ -63,7 +63,7 @@ where
set_log_level(ctx);
- let device = match ctx.model {
+ let device = match ctx.config.model {
Some(model) => manager.connect_model(model.into()).with_context(|| {
anyhow::anyhow!("Nitrokey {} device not found", model.as_user_facing_str())
})?,
@@ -83,7 +83,7 @@ where
set_log_level(ctx);
- if let Some(model) = ctx.model {
+ if let Some(model) = ctx.config.model {
if model != args::DeviceModel::Storage {
anyhow::bail!("This command is only available on the Nitrokey Storage");
}