diff --git a/src/cliparser.rs b/src/cliparser.rs index ff7e89ecb..a54f29c12 100644 --- a/src/cliparser.rs +++ b/src/cliparser.rs @@ -1,4 +1,4 @@ -use clap::Parser; +use clap::{CommandFactory, Parser}; #[derive(Debug, Parser)] #[command(author, version, about, long_about = None)] @@ -68,5 +68,14 @@ pub struct CliArgs { } pub fn parse() -> CliArgs { - CliArgs::parse() + let args = CliArgs::parse(); + + if std::env::args().len() == 1 { + CliArgs::command() + .print_help() + .expect("Failed to print help output"); + std::process::exit(1); + } + + args } diff --git a/src/main.rs b/src/main.rs index ed46ef5fc..ff6a61894 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,7 @@ fn main() { // Initialize logging env_logger::init(); - // Process command line aguments + // Process command line arguments let mut cliargs = cliparser::parse(); // If --list was specified, just display a list of signatures and return @@ -66,11 +66,6 @@ fn main() { cliargs.file_name = Some(STDIN.to_string()); } - // If --list was not specified, a target file must be provided - if cliargs.file_name.is_none() { - panic!("No target file name specified! Try --help."); - } - let mut json_logger = json::JsonLogger::new(cliargs.log); // If entropy analysis was requested, generate the entropy graph and return