@@ -43,7 +43,7 @@ std::vector<std::string> reorder_args_for_cli11(int argc, char** argv)
4343 positionals.reserve (static_cast <size_t >(argc));
4444
4545 auto is_long_with_value = [](const std::string& name) {
46- return name == " --output" || name == " --dump" || name == " --extract" || name == " --plugins" ;
46+ return name == " --output" || name == " --dump" || name == " --extract" || name == " --plugins" || name == " --log-level " ;
4747 };
4848
4949 bool end_of_options = false ;
@@ -131,6 +131,7 @@ bool parse_args(Options& opts, int argc, char**argv, const HelpPrinter& help_pri
131131 ->required ()
132132 ->type_name (" FILE" );
133133 app.add_flag (" -r,--recursive" , opts.recursive , " Scan all files in a directory (subdirectories will be ignored)." );
134+ app.add_flag (" -q,--quiet" , opts.quiet , " Only display errors." );
134135 auto * output_opt = app.add_option (" -o,--output" , opts.output , " The output format. May be 'raw' (default) or 'json'." );
135136 auto * dump_opt = app.add_option (" -d,--dump" , opts.dump ,
136137 " Dump PE information. Available choices are any combination of: "
@@ -146,6 +147,18 @@ bool parse_args(Options& opts, int argc, char**argv, const HelpPrinter& help_pri
146147 " Analyze the binary with additional plugins. (may slow down the analysis!)" );
147148 plugins_opt->expected (1 );
148149 plugins_opt->multi_option_policy (CLI ::MultiOptionPolicy::TakeAll);
150+ auto * log_level_opt = app.add_option (" --log-level" , opts.log_level ,
151+ " Set log verbosity. Accepted values: off, error, warning, info, debug." );
152+
153+ if (argc <= 1 )
154+ {
155+ if (help_printer) {
156+ help_printer (app, argv[0 ]);
157+ } else {
158+ print_help_default (app, argv[0 ]);
159+ }
160+ return false ;
161+ }
149162
150163 try
151164 {
@@ -175,9 +188,23 @@ bool parse_args(Options& opts, int argc, char**argv, const HelpPrinter& help_pri
175188
176189 opts.output_set = output_opt->count () > 0 ;
177190 opts.extract_set = extract_opt->count () > 0 ;
191+ opts.log_level_set = log_level_opt->count () > 0 ;
178192 opts.dump = split_comma_values (opts.dump );
179193 opts.plugins = split_comma_values (opts.plugins );
180194
195+ if (opts.quiet && !opts.log_level_set ) {
196+ opts.log_level = " error" ;
197+ opts.log_level_set = true ;
198+ }
199+ if (opts.log_level_set ) {
200+ utils::LogLevel level = utils::LogLevel::WARNING ;
201+ if (!utils::parse_log_level (opts.log_level , level)) {
202+ PRINT_ERROR << " Invalid log level \" " << opts.log_level
203+ << " \" . Expected one of: off, error, warning, info, debug." << std::endl;
204+ return false ;
205+ }
206+ }
207+
181208 if (opts.version )
182209 {
183210 std::stringstream ss;
0 commit comments