Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed output when no command line options are specified #818

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/cliparser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::Parser;
use clap::{CommandFactory, Parser};

#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -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
}
7 changes: 1 addition & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading