Commits

Jan Borsodi committed 72f5772

Improved compatibility with argparse>=1.1 by turning the version option into an proper argument line if 1.1 is used, this also means that -v no longer returns the version.

Comments (0)

Files changed (1)

         ui.config.read(["hob_private.conf"])
     ui.config.reads("[hob]\ntarget=current\n")
     _exts.setup(ui, cmds)
-    parser = argparse.ArgumentParser(version=__version__, prog=__program__)
+    parser_args = dict(prog=__program__)
+    from distutils.version import LooseVersion as Version
+    if Version(argparse.__version__) < "1.1":
+        parser_args["version"] = __version__
+    parser = argparse.ArgumentParser(**parser_args)
+    if "version" not in parser_args:
+        parser.add_argument("--version", action="version", version=__version__)
     cmds.setup(parser)
     opts = parser.parse_args(args)
     cmds.loadconfig(ui.config, opts)