Commit 93c1ea3a authored by MinchinWeb's avatar MinchinWeb

Allow `--version` as an alias for `-v`

Add a long version option
parent 14ab34d6
...@@ -26,6 +26,7 @@ from topydo.lib.Color import AbstractColor, Color ...@@ -26,6 +26,7 @@ from topydo.lib.Color import AbstractColor, Color
from topydo.lib.TopydoString import TopydoString from topydo.lib.TopydoString import TopydoString
MAIN_OPTS = "ac:C:d:ht:v" MAIN_OPTS = "ac:C:d:ht:v"
MAIN_LONG_OPTS = ('version')
READ_ONLY_COMMANDS = ('List', 'ListContext', 'ListProject') READ_ONLY_COMMANDS = ('List', 'ListContext', 'ListProject')
...@@ -171,7 +172,7 @@ class CLIApplicationBase(object): ...@@ -171,7 +172,7 @@ class CLIApplicationBase(object):
args = sys.argv[1:] args = sys.argv[1:]
try: try:
opts, args = getopt.getopt(args, MAIN_OPTS) opts, args = getopt.getopt(args, MAIN_OPTS, MAIN_LONG_OPTS)
except getopt.GetoptError as e: except getopt.GetoptError as e:
error(str(e)) error(str(e))
sys.exit(1) sys.exit(1)
...@@ -191,7 +192,7 @@ class CLIApplicationBase(object): ...@@ -191,7 +192,7 @@ class CLIApplicationBase(object):
overrides[('topydo', 'filename')] = value overrides[('topydo', 'filename')] = value
elif opt == "-d": elif opt == "-d":
overrides[('topydo', 'archive_filename')] = value overrides[('topydo', 'archive_filename')] = value
elif opt == "-v": elif opt in ("-v", "--version"):
version() version()
else: else:
self._usage() self._usage()
......
...@@ -20,7 +20,7 @@ import getopt ...@@ -20,7 +20,7 @@ import getopt
import sys import sys
from topydo.ui.cli.CLI import CLIApplication from topydo.ui.cli.CLI import CLIApplication
from topydo.ui.CLIApplicationBase import MAIN_OPTS, error from topydo.ui.CLIApplicationBase import MAIN_OPTS, MAIN_LONG_OPTS, error
# enable color on windows CMD # enable color on windows CMD
if "win32" in sys.platform: if "win32" in sys.platform:
...@@ -34,7 +34,7 @@ def main(): ...@@ -34,7 +34,7 @@ def main():
args = sys.argv[1:] args = sys.argv[1:]
try: try:
_, args = getopt.getopt(args, MAIN_OPTS) _, args = getopt.getopt(args, MAIN_OPTS, MAIN_LONG_OPTS)
except getopt.GetoptError as e: except getopt.GetoptError as e:
error(str(e)) error(str(e))
sys.exit(1) sys.exit(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment