]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
display help, or version before parsing config file 36/head
authorJason Ish <ish@unx.ca>
Wed, 25 Apr 2018 21:07:59 +0000 (15:07 -0600)
committerJason Ish <ish@unx.ca>
Thu, 26 Apr 2018 12:50:59 +0000 (06:50 -0600)
Handle the display of version info and help before parsing any
configuration data.

suricata/update/main.py

index df182fdb6b06dab60d6e4b7e2aa932da24457829..2b9335fcfc7b9950829e7a756f5e956c65c54886 100644 (file)
@@ -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: