fix --quit not conflicting with --info and use default value for log level

This commit is contained in:
Leonard Steppy 2024-12-17 05:49:37 +01:00
parent 7f3adc9bc2
commit 4a3fd978a4

View File

@ -1,8 +1,8 @@
mod action; mod action;
mod file; mod file;
mod logger;
mod os_string_builder; mod os_string_builder;
mod server; mod server;
mod logger;
use crate::action::{Action, FileAction, ServerActions}; use crate::action::{Action, FileAction, ServerActions};
use crate::file::{FileMatcher, FileNameInfo}; use crate::file::{FileMatcher, FileNameInfo};
@ -50,7 +50,7 @@ struct Args {
#[arg(short, long, default_value = "false", conflicts_with_all = ["info"])] #[arg(short, long, default_value = "false", conflicts_with_all = ["info"])]
quiet: bool, quiet: bool,
/// Log additional debugging info /// Log additional debugging info
#[arg(short='v', long, default_value = "false")] #[arg(short = 'v', long, default_value = "false")]
info: bool, info: bool,
} }
@ -121,7 +121,16 @@ enum OldVersionPolicy {
fn main() -> Result<(), String> { fn main() -> Result<(), String> {
let args = Args::parse(); 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 mut configured_servers = LazyCell::new(parse_server_configuration_from_env);
let servers = args let servers = args