From 3f632969a9ceac5452ab23d55c923aa5b9aa8ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Thu, 5 Sep 2024 08:23:40 +0200 Subject: [PATCH] fix: warn of unused loglevel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: #15 Signed-off-by: Christina Sørensen --- crates/nix-weather/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/nix-weather/src/main.rs b/crates/nix-weather/src/main.rs index fcc11a7..d394f7f 100644 --- a/crates/nix-weather/src/main.rs +++ b/crates/nix-weather/src/main.rs @@ -35,10 +35,13 @@ async fn main() -> io::Result<()> { let matches = cli::build_cli().get_matches(); - // TODO + /// If the users inputs more -v flags than we have log levels, send them a + /// message informing them. + let mut very_bose = false; + match matches .get_one::("verbose") - .expect("Count's are defaulted") + .expect("Counts aren't defaulted") { 0 => env::set_var("RUST_LOG", "error"), 1 => env::set_var("RUST_LOG", "warn"), @@ -46,7 +49,7 @@ async fn main() -> io::Result<()> { 3 => env::set_var("RUST_LOG", "debug"), 4 => env::set_var("RUST_LOG", "trace"), _ => { - log::trace!("More than four -v flags don't increase log level."); + very_bose = true; env::set_var("RUST_LOG", "trace") } } @@ -61,6 +64,10 @@ async fn main() -> io::Result<()> { .init(); } + if very_bose { + log::trace!("More than four -v flags don't increase log level."); + } + if let Some(name) = matches.get_one::("name") { host_name = name.to_owned(); } else {