From 105e087abcfb7491cc518cf1a1fd58bfc0ccb54c Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 2 Jul 2021 23:41:56 +0000 Subject: fix(whirl_cli): method of comparing argument when evaluating logger style This commit adds extra error checking to the logger style evaluator as previously, Whirl would panic if no arguments were passed via the command line because an expression within the evaluator would still do a comparison to the first index of the command line arguments. --- crates/whirl/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/whirl/src/lib.rs b/crates/whirl/src/lib.rs index e88c818..9297ccc 100644 --- a/crates/whirl/src/lib.rs +++ b/crates/whirl/src/lib.rs @@ -59,8 +59,15 @@ impl Whirl { flexi_logger::Logger::try_with_str(whirl_common::log::calculate_log_level()).unwrap(); if std::env::var("LOG_FILE").unwrap_or_else(|_| "true".to_string()) == "false" || !whirl_config::Config::get().whirlsplash.log.file - || std::env::args().collect::>()[1] == "clean" - // Cheeky as all hell. + || ({ + // Cheeky as all hell. + let args = std::env::args().collect::>(); + if args.len() == 2 { + args[1] == "clean" + } else { + false + } + }) { logger.start()?; } else { -- cgit v1.2.3