From 88b243bca17ab549342738bce98a1c678f98e754 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 23 Jan 2020 10:54:09 +0100 Subject: 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) --- src/commands.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/commands.rs') 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"); } -- cgit v1.2.1