From 4a3fd978a4ed054f313cf526a5c2ec4b76c0bb2c Mon Sep 17 00:00:00 2001 From: Leonard Steppy Date: Tue, 17 Dec 2024 05:49:37 +0100 Subject: [PATCH] fix --quit not conflicting with --info and use default value for log level --- src/main.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 54ea392..29d4982 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ mod action; mod file; +mod logger; mod os_string_builder; mod server; -mod logger; use crate::action::{Action, FileAction, ServerActions}; use crate::file::{FileMatcher, FileNameInfo}; @@ -50,7 +50,7 @@ struct Args { #[arg(short, long, default_value = "false", conflicts_with_all = ["info"])] quiet: bool, /// Log additional debugging info - #[arg(short='v', long, default_value = "false")] + #[arg(short = 'v', long, default_value = "false")] info: bool, } @@ -120,8 +120,17 @@ enum OldVersionPolicy { fn main() -> Result<(), String> { let args = Args::parse(); - - let logger = Logger::default(); + + let logger = Logger { + //all the below options are conflicting with each other so an if else is fine + level: if args.quiet { + LogLevel::Error + } else if args.info { + LogLevel::Debug + } else { + args.log_level + }, + }; let mut configured_servers = LazyCell::new(parse_server_configuration_from_env); let servers = args