[Pkg-privacy-commits] [onionbalance] 106/117: Add --version argument to the command line

Donncha O'Cearbahill donncha-guest at moszumanska.debian.org
Wed Dec 16 23:18:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

donncha-guest pushed a commit to branch debian/sid
in repository onionbalance.

commit cfe1822cf8d7b9c96c5591f1b843cb3cd7bb168e
Author: Donncha O'Cearbhaill <donncha at donncha.is>
Date:   Sat Dec 12 16:11:10 2015 +0100

    Add --version argument to the command line
---
 onionbalance/manager.py  | 10 +++++++++-
 onionbalance/settings.py | 16 ++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/onionbalance/manager.py b/onionbalance/manager.py
index 9588576..4eab533 100644
--- a/onionbalance/manager.py
+++ b/onionbalance/manager.py
@@ -48,7 +48,15 @@ def parse_cmd_args():
                              "in ascending order: debug, info, warning, "
                              "error, critical).  The default is info.")
 
-    return parser.parse_args()
+    parser.add_argument("--version", action='store_true',
+                        help="Display the onionbalance version and exit.")
+
+    args = parser.parse_args()
+    if args.version:
+        print("onionbalance version: {}".format(onionbalance.__version__))
+        sys.exit(0)
+
+    return args
 
 
 def main():
diff --git a/onionbalance/settings.py b/onionbalance/settings.py
index e39bbb0..741d65b 100644
--- a/onionbalance/settings.py
+++ b/onionbalance/settings.py
@@ -158,7 +158,15 @@ def parse_cmd_args():
 
     # .. todo:: Add option to specify HS host and port for instance torrc
 
-    return parser.parse_args()
+    parser.add_argument("--version", action='store_true',
+                        help="Display the onionbalance version and exit.")
+
+    args = parser.parse_args()
+    if args.version:
+        print("onionbalance version: {}".format(onionbalance.__version__))
+        sys.exit(0)
+
+    return args
 
 
 def generate_config():
@@ -166,14 +174,14 @@ def generate_config():
     Entry point for interactive config file generation.
     """
 
+    # Parse initial command line options
+    args = parse_cmd_args()
+
     # Simplify the logging output for the command line tool
     logger = log.get_config_generator_logger()
 
     logger.info("Beginning OnionBalance config generation.")
 
-    # Parse initial command line options
-    args = parse_cmd_args()
-
     # If CLI options have been provided, don't enter interactive mode
     # Crude check to see if any options beside --verbosity are set.
     verbose = True if '-v' in sys.argv else False

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionbalance.git



More information about the Pkg-privacy-commits mailing list