From 24fd507f17f6b53ca6781664fd6b54b94bb3e1ad Mon Sep 17 00:00:00 2001 From: pickworthi <82284576+pickworthi@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:02:21 +0000 Subject: [PATCH] Added -v, --version command line option (#273) * Added -v, --version command line option * Corrected parsing of -v and --version * Review corrections --- umu/umu_run.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/umu/umu_run.py b/umu/umu_run.py index 72e479cf1..e39a657d4 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -63,6 +63,9 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 ), formatter_class=RawTextHelpFormatter, ) + parser.add_argument("-v", "--version", action='store_true', + help="show this version and exit" + ) parser.add_argument( "--config", help=("path to TOML file (requires Python 3.11+)") ) @@ -77,6 +80,18 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 parser.print_help(sys.stderr) sys.exit(1) + # Show version + # Need to avoid clashes with later options (for example: wineboot -u) + # but parse_args scans the whole command line. + # So look at the first argument and see if we have -v or --version + # in sort of the same way parse_args would. + if sys.argv[1].lower().endswith(("--version", "-v")): + print( + f"umu-launcher version {__version__} ({sys.version})", + file=sys.stderr + ) + sys.exit(0) + # Winetricks # Exit if no winetricks verbs were passed if sys.argv[1].endswith("winetricks") and not sys.argv[2:]: