diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-01-23 10:54:09 +0100 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2020-09-01 21:12:43 -0700 |
commit | 3f430bac70a946c776a930fabc5b64a788113452 (patch) | |
tree | b1989fd259a159eb7982002155dc8b482948c1cd /src/commands.rs | |
parent | bb592ad9909c84c3c72252e1775b1cd2abc1e881 (diff) | |
download | nitrocli-3f430bac70a946c776a930fabc5b64a788113452.tar.gz nitrocli-3f430bac70a946c776a930fabc5b64a788113452.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.rs | 6 |
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"); } |