[Pkg-privacy-commits] [onionbalance] 108/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 e452c00c930caafdfa6310b026b851624d318d51
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  | 13 ++++---------
 onionbalance/settings.py | 13 ++++---------
 2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/onionbalance/manager.py b/onionbalance/manager.py
index 4eab533..6216560 100644
--- a/onionbalance/manager.py
+++ b/onionbalance/manager.py
@@ -48,22 +48,17 @@ def parse_cmd_args():
                              "in ascending order: debug, info, warning, "
                              "error, critical).  The default is info.")
 
-    parser.add_argument("--version", action='store_true',
-                        help="Display the onionbalance version and exit.")
+    parser.add_argument('--version', action='version',
+                        version='onionbalance %s' % onionbalance.__version__)
 
-    args = parser.parse_args()
-    if args.version:
-        print("onionbalance version: {}".format(onionbalance.__version__))
-        sys.exit(0)
-
-    return args
+    return parser
 
 
 def main():
     """
     Entry point when invoked over the command line.
     """
-    args = parse_cmd_args()
+    args = parse_cmd_args().parse_args()
     config_file_options = settings.parse_config_file(args.config)
 
     # Update global configuration with options specified in the config file
diff --git a/onionbalance/settings.py b/onionbalance/settings.py
index 741d65b..59cd748 100644
--- a/onionbalance/settings.py
+++ b/onionbalance/settings.py
@@ -158,15 +158,10 @@ def parse_cmd_args():
 
     # .. todo:: Add option to specify HS host and port for instance torrc
 
-    parser.add_argument("--version", action='store_true',
-                        help="Display the onionbalance version and exit.")
+    parser.add_argument('--version', action='version',
+                        version='onionbalance %s' % onionbalance.__version__)
 
-    args = parser.parse_args()
-    if args.version:
-        print("onionbalance version: {}".format(onionbalance.__version__))
-        sys.exit(0)
-
-    return args
+    return parser
 
 
 def generate_config():
@@ -175,7 +170,7 @@ def generate_config():
     """
 
     # Parse initial command line options
-    args = parse_cmd_args()
+    args = parse_cmd_args().parse_args()
 
     # Simplify the logging output for the command line tool
     logger = log.get_config_generator_logger()

-- 
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