From: Jason Ish Date: Wed, 25 Apr 2018 21:07:59 +0000 (-0600) Subject: display help, or version before parsing config file X-Git-Tag: 1.0.0rc1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74bf64e706162de9bb1731e801609e0a667a27d8;p=thirdparty%2Fsuricata-update.git display help, or version before parsing config file Handle the display of version info and help before parsing any configuration data. --- diff --git a/suricata/update/main.py b/suricata/update/main.py index df182fd..2b9335f 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -1130,6 +1130,29 @@ def _main(): if args.quiet: logger.setLevel(logging.WARNING) + logger.debug("This is suricata-update version %s (rev: %s); Python: %s" % ( + version, revision, sys.version.replace("\n", "- "))) + + if args.dump_sample_configs: + return dump_sample_configs() + + if args.version: + print("suricata-update version %s (rev: %s)" % (version, revision)) + return 0 + + if args.help: + print(update_parser.format_help()) + print("""other commands: + update-sources Update the source index + list-sources List available sources + enable-source Enable a source from the index + disable-source Disable an enabled source + remove-source Remove an enabled or disabled source + list-enabled-sources List all enabled sources + add-source Add a new source by URL +""") + return 0 + config.init(args) # Error out if any reserved/unimplemented arguments were set. @@ -1144,9 +1167,6 @@ def _main(): logger.error("--%s not implemented", arg) return 1 - logger.debug("This is suricata-update version %s (rev: %s); Python: %s" % ( - version, revision, sys.version.replace("\n", "- "))) - suricata_path = config.get("suricata") # Now parse the Suricata version. If provided on the command line, @@ -1191,26 +1211,6 @@ def _main(): logger.error("Unknown command: %s", args.subcommand) return 1 - if args.dump_sample_configs: - return dump_sample_configs() - - if args.version: - print("suricata-update version %s (rev: %s)" % (version, revision)) - return 0 - - if args.help: - print(update_parser.format_help()) - print("""other commands: - update-sources Update the source index - list-sources List available sources - enable-source Enable a source from the index - disable-source Disable an enabled source - remove-source Remove an enabled or disabled source - list-enabled-sources List all enabled sources - add-source Add a new source by URL -""") - return 0 - # If --no-ignore was provided, clear any ignores provided in the # config. if args.no_ignore: