From b4b7605e1f947ef0c58d94354c10fd74fd010a53 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 23 Jan 2020 14:04:42 +0100 Subject: Use envy to parse environment variables for Config This patch uses the envy crate to parse the environment. A variable NITROCLI_KEY can be used to overwrite the configuration for *key*. This has the side effect that the NITROCLI_NO_CACHE variable is evaluated as a boolean variable (instead of only checking whether it is set). We also accept two new variables, NITROCLI_MODEL and NITROCLI_VERBOSITY. --- src/main.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 3535a91..b53358e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,7 +84,6 @@ const NITROCLI_USER_PIN: &str = "NITROCLI_USER_PIN"; const NITROCLI_NEW_ADMIN_PIN: &str = "NITROCLI_NEW_ADMIN_PIN"; const NITROCLI_NEW_USER_PIN: &str = "NITROCLI_NEW_USER_PIN"; const NITROCLI_PASSWORD: &str = "NITROCLI_PASSWORD"; -const NITROCLI_NO_CACHE: &str = "NITROCLI_NO_CACHE"; trait Stdio { fn stdio(&mut self) -> (&mut dyn io::Write, &mut dyn io::Write); @@ -206,11 +205,7 @@ fn main() { let mut stderr = io::stderr(); let rc = match config::Config::load() { - Ok(mut config) => { - if env::var_os(NITROCLI_NO_CACHE).is_some() { - config.no_cache = true; - } - + Ok(config) => { let args = env::args().collect::>(); let ctx = &mut RunCtx { stdout: &mut stdout, -- cgit v1.2.1