From c547fe2e7193e527668a9826dd955d8a70108b29 Mon Sep 17 00:00:00 2001 From: pickworthi Date: Wed, 13 Nov 2024 16:45:57 +0000 Subject: [PATCH 1/3] Added -v, --version command line option --- umu/umu_run.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/umu/umu_run.py b/umu/umu_run.py index 72e479cf1..fdce181ef 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 the version and exit" + ) parser.add_argument( "--config", help=("path to TOML file (requires Python 3.11+)") ) @@ -77,6 +80,11 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 parser.print_help(sys.stderr) sys.exit(1) + c_args = parser.parse_args() + if c_args.version: + print(f"umu-launcher version {__version__} ({sys.version})", file=sys.stderr) + sys.exit(1) + # Winetricks # Exit if no winetricks verbs were passed if sys.argv[1].endswith("winetricks") and not sys.argv[2:]: From 8e01940152b3d755e1ad6d6c08683ca7ca6312d4 Mon Sep 17 00:00:00 2001 From: pickworthi Date: Wed, 13 Nov 2024 18:20:23 +0000 Subject: [PATCH 2/3] Corrected parsing of -v and --version --- umu/umu_run.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index fdce181ef..63a12801f 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -80,8 +80,12 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 parser.print_help(sys.stderr) sys.exit(1) - c_args = parser.parse_args() - if c_args.version: + # 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() == "-v" or sys.argv[1].lower().startswith("--v"): print(f"umu-launcher version {__version__} ({sys.version})", file=sys.stderr) sys.exit(1) From 78b31adc66aed9324f010c66c477a34ad853dc5c Mon Sep 17 00:00:00 2001 From: pickworthi Date: Wed, 13 Nov 2024 22:42:46 +0000 Subject: [PATCH 3/3] Review corrections --- umu/umu_run.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/umu/umu_run.py b/umu/umu_run.py index 63a12801f..e39a657d4 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -64,7 +64,7 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 formatter_class=RawTextHelpFormatter, ) parser.add_argument("-v", "--version", action='store_true', - help="show the version and exit" + help="show this version and exit" ) parser.add_argument( "--config", help=("path to TOML file (requires Python 3.11+)") @@ -85,9 +85,12 @@ def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 # 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() == "-v" or sys.argv[1].lower().startswith("--v"): - print(f"umu-launcher version {__version__} ({sys.version})", file=sys.stderr) - sys.exit(1) + 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