Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3740a97

Browse files
committed
Adding a --version switch like all command line programs have
1 parent 7447773 commit 3740a97

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/parse/cmdline.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from lib.core.settings import DUMMY_URL
2222
from lib.core.settings import IS_WIN
2323
from lib.core.settings import MAX_HELP_OPTION_LENGTH
24+
from lib.core.settings import VERSION_STRING
2425

2526
def cmdLineParser():
2627
"""
@@ -37,6 +38,10 @@ def cmdLineParser():
3738
action="store_true",
3839
help="Show advanced help message and exit")
3940

41+
parser.add_option("--version", dest="showVersion",
42+
action="store_true",
43+
help="Show version string and exit")
44+
4045
parser.add_option("-v", dest="verbose", type="int",
4146
help="Verbosity level: 0-6 (default %d)" % defaults.verbose)
4247

@@ -740,6 +745,9 @@ def _(self, *args):
740745
for i in xrange(len(sys.argv)):
741746
if sys.argv[i] == '-hh':
742747
sys.argv[i] = '-h'
748+
elif sys.argv[i] == '--version':
749+
print VERSION_STRING
750+
raise SystemExit
743751
elif sys.argv[i] == '-h':
744752
advancedHelp = False
745753
for group in parser.option_groups[:]:

0 commit comments

Comments
 (0)