diff options
| author | Fuwn <[email protected]> | 2021-07-02 23:41:56 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-02 23:41:56 +0000 |
| commit | 105e087abcfb7491cc518cf1a1fd58bfc0ccb54c (patch) | |
| tree | d29fe57abe656ca53d1f0cea832e76f0f498e717 | |
| parent | build(nix): update deps (diff) | |
| download | whirl-105e087abcfb7491cc518cf1a1fd58bfc0ccb54c.tar.xz whirl-105e087abcfb7491cc518cf1a1fd58bfc0ccb54c.zip | |
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.
| -rw-r--r-- | crates/whirl/src/lib.rs | 11 |
1 files 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::<Vec<_>>()[1] == "clean" - // Cheeky as all hell. + || ({ + // Cheeky as all hell. + let args = std::env::args().collect::<Vec<_>>(); + if args.len() == 2 { + args[1] == "clean" + } else { + false + } + }) { logger.start()?; } else { |