Add --version command
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 5 May 2018 18:17:50 +0000 (20:17 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 5 May 2018 18:17:50 +0000 (20:17 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
nitsi.in

index a87aa0a..460487d 100755 (executable)
--- a/nitsi.in
+++ b/nitsi.in
@@ -26,16 +26,22 @@ if __name__ == "__main__":
 
     parser.add_argument("-d", "--directory", dest="dir")
 
 
     parser.add_argument("-d", "--directory", dest="dir")
 
+    parser.add_argument("-v" "--version", help="Display version and exit",
+                    action="store_true", dest="version")
+
     args = parser.parse_args()
 
     args = parser.parse_args()
 
-    currenttest = test(args.dir)
-    currenttest.read_settings()
-    currenttest.virtual_environ_setup()
-    currenttest.load_recipe()
-    try:
-        currenttest.virtual_environ_start()
-        currenttest.run_recipe()
-    except BaseException as e:
-        print(e)
-    finally:
-        currenttest.virtual_environ_stop()
\ No newline at end of file
+    if args.version:
+        logger.info("nitsi version: {}".format("@PACKAGE_VERSION@"))
+    else:
+        currenttest = test(args.dir)
+        currenttest.read_settings()
+        currenttest.virtual_environ_setup()
+        currenttest.load_recipe()
+        try:
+            currenttest.virtual_environ_start()
+            currenttest.run_recipe()
+        except BaseException as e:
+            print(e)
+        finally:
+            currenttest.virtual_environ_stop()
\ No newline at end of file