Skip to content

Commit

Permalink
Merge pull request #818 from ReFirmLabs/show_help
Browse files Browse the repository at this point in the history
Fixed output when no command line options are specified
  • Loading branch information
devttys0 authored Jan 6, 2025
2 parents 9b14423 + a1df68b commit 2f6ca77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
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

0 comments on commit 2f6ca77

Please sign in to comment.