Fix: show usage when hayabusa has no args
This commit is contained in:
86
src/main.rs
86
src/main.rs
@@ -73,6 +73,14 @@ impl App {
|
||||
|
||||
fn exec(&mut self) {
|
||||
let analysis_start_time: DateTime<Local> = Local::now();
|
||||
|
||||
// Show usage when no arguments.
|
||||
if std::env::args().len() == 1 {
|
||||
println!("{}", configs::CONFIG.read().unwrap().args.usage());
|
||||
println!();
|
||||
return;
|
||||
}
|
||||
|
||||
if !configs::CONFIG.read().unwrap().args.is_present("quiet") {
|
||||
self.output_logo();
|
||||
println!();
|
||||
@@ -106,42 +114,6 @@ impl App {
|
||||
return;
|
||||
}
|
||||
|
||||
if configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.is_present("level-tuning")
|
||||
{
|
||||
let level_tuning_config_path = configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.value_of("level-tuning")
|
||||
.unwrap_or("./config/level_tuning.txt")
|
||||
.to_string();
|
||||
|
||||
if Path::new(&level_tuning_config_path).exists() {
|
||||
if let Err(err) = LevelTuning::run(
|
||||
&level_tuning_config_path,
|
||||
configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.value_of("rules")
|
||||
.unwrap_or("rules"),
|
||||
) {
|
||||
AlertMessage::alert(&mut BufWriter::new(std::io::stderr().lock()), &err).ok();
|
||||
}
|
||||
} else {
|
||||
AlertMessage::alert(
|
||||
&mut BufWriter::new(std::io::stderr().lock()),
|
||||
"Need rule_levels.txt file to use --level-tuning option",
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if !Path::new("./config").exists() {
|
||||
AlertMessage::alert(
|
||||
&mut BufWriter::new(std::io::stderr().lock()),
|
||||
@@ -150,11 +122,7 @@ impl App {
|
||||
.ok();
|
||||
return;
|
||||
}
|
||||
if configs::CONFIG.read().unwrap().args.args.is_empty() {
|
||||
println!("{}", configs::CONFIG.read().unwrap().args.usage());
|
||||
println!();
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(csv_path) = configs::CONFIG.read().unwrap().args.value_of("output") {
|
||||
if Path::new(csv_path).exists() {
|
||||
AlertMessage::alert(
|
||||
@@ -220,7 +188,43 @@ impl App {
|
||||
{
|
||||
self.print_contributors();
|
||||
return;
|
||||
} else if configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.is_present("level-tuning")
|
||||
{
|
||||
println!("Level_tuning: {:?}", std::env::args().len());
|
||||
let level_tuning_config_path = configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.value_of("level-tuning")
|
||||
.unwrap_or("./config/level_tuning.txt")
|
||||
.to_string();
|
||||
|
||||
if Path::new(&level_tuning_config_path).exists() {
|
||||
if let Err(err) = LevelTuning::run(
|
||||
&level_tuning_config_path,
|
||||
configs::CONFIG
|
||||
.read()
|
||||
.unwrap()
|
||||
.args
|
||||
.value_of("rules")
|
||||
.unwrap_or("rules"),
|
||||
) {
|
||||
AlertMessage::alert(&mut BufWriter::new(std::io::stderr().lock()), &err).ok();
|
||||
}
|
||||
} else {
|
||||
AlertMessage::alert(
|
||||
&mut BufWriter::new(std::io::stderr().lock()),
|
||||
"Need rule_levels.txt file to use --level-tuning option",
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let analysis_end_time: DateTime<Local> = Local::now();
|
||||
let analysis_duration = analysis_end_time.signed_duration_since(analysis_start_time);
|
||||
println!();
|
||||
|
||||
Reference in New Issue
Block a user