From: Victor Julien Date: Wed, 11 Jun 2025 10:48:16 +0000 (+0200) Subject: commandline: add --help option X-Git-Tag: suricata-8.0.0-rc1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa3311a25309c78d836469eb851742ee40d3450b;p=thirdparty%2Fsuricata.git commandline: add --help option Acts same as -h. --- diff --git a/src/suricata.c b/src/suricata.c index 023c1dc160..66c2df0c28 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -1359,6 +1359,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) // clang-format off struct option long_opts[] = { + {"help", 0, 0, 0}, {"dump-config", 0, &dump_config, 1}, {"dump-features", 0, &dump_features, 1}, {"pfring", optional_argument, 0, 0}, @@ -1451,8 +1452,11 @@ TmEcode SCParseCommandLine(int argc, char **argv) while ((opt = getopt_long(argc, argv, short_opts, long_opts, &option_index)) != -1) { switch (opt) { case 0: - if (strcmp((long_opts[option_index]).name , "pfring") == 0 || - strcmp((long_opts[option_index]).name , "pfring-int") == 0) { + if (strcmp((long_opts[option_index]).name, "help") == 0) { + suri->run_mode = RUNMODE_PRINT_USAGE; + return TM_ECODE_OK; + } else if (strcmp((long_opts[option_index]).name, "pfring") == 0 || + strcmp((long_opts[option_index]).name, "pfring-int") == 0) { #ifdef HAVE_PFRING /* TODO: Which plugin? */ suri->run_mode = RUNMODE_PLUGIN; @@ -1469,8 +1473,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) "to pass --enable-pfring to configure when building."); return TM_ECODE_FAILED; #endif /* HAVE_PFRING */ - } - else if(strcmp((long_opts[option_index]).name , "pfring-cluster-id") == 0){ + } else if (strcmp((long_opts[option_index]).name, "pfring-cluster-id") == 0) { #ifdef HAVE_PFRING if (SCConfSetFinal("pfring.cluster-id", optarg) != 1) { SCLogError("failed to set pfring.cluster-id"); @@ -1481,8 +1484,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) "to pass --enable-pfring to configure when building."); return TM_ECODE_FAILED; #endif /* HAVE_PFRING */ - } - else if(strcmp((long_opts[option_index]).name , "pfring-cluster-type") == 0){ + } else if (strcmp((long_opts[option_index]).name, "pfring-cluster-type") == 0) { #ifdef HAVE_PFRING if (SCConfSetFinal("pfring.cluster-type", optarg) != 1) { SCLogError("failed to set pfring.cluster-type"); @@ -1493,12 +1495,10 @@ TmEcode SCParseCommandLine(int argc, char **argv) "to pass --enable-pfring to configure when building."); return TM_ECODE_FAILED; #endif /* HAVE_PFRING */ - } - else if (strcmp((long_opts[option_index]).name , "capture-plugin") == 0){ + } else if (strcmp((long_opts[option_index]).name, "capture-plugin") == 0) { suri->run_mode = RUNMODE_PLUGIN; suri->capture_plugin_name = optarg; - } - else if (strcmp((long_opts[option_index]).name , "capture-plugin-args") == 0){ + } else if (strcmp((long_opts[option_index]).name, "capture-plugin-args") == 0) { suri->capture_plugin_args = optarg; } else if (strcmp((long_opts[option_index]).name, "dpdk") == 0) { if (ParseCommandLineDpdk(suri, optarg) != TM_ECODE_OK) {