adjusted default value when level-tuning option is not defined

This commit is contained in:
DustInDark
2022-06-26 12:16:27 +09:00
parent 15ffd509ab
commit eec5df3ff3
2 changed files with 12 additions and 13 deletions

View File

@@ -191,11 +191,10 @@ pub struct Config {
/// Tune alert levels (default: ./rules/config/level_tuning.txt)
#[clap(
long = "level-tuning",
default_value = "./rules/config/level_tuning.txt",
hide_default_value = true,
value_name = "LEVEL_TUNING_FILE"
)]
pub level_tuning: PathBuf,
pub level_tuning: Option<Option<String>>,
/// Quiet mode: do not display the launch banner
#[clap(short, long)]

View File

@@ -251,18 +251,18 @@ impl App {
} else if configs::CONFIG.read().unwrap().args.contributors {
self.print_contributors();
return;
} else if std::env::args()
.into_iter()
.any(|arg| arg.contains("level-tuning"))
} else if configs::CONFIG.read().unwrap().args.level_tuning.is_some()
{
let level_tuning_config_path = configs::CONFIG
.read()
.unwrap()
.args
.level_tuning
.as_path()
.display()
.to_string();
let level_tuning_val = &configs::CONFIG
.read()
.unwrap()
.args
.level_tuning.clone().unwrap();
let level_tuning_config_path = match level_tuning_val {
Some (path) => path.to_owned(),
_ => "./rules/config/level_tuning.txt".to_string(),
};
if Path::new(&level_tuning_config_path).exists() {
if let Err(err) = LevelTuning::run(