Skip to content

Commit

Permalink
Added -v, --version command line option (#273)
Browse files Browse the repository at this point in the history
* Added -v, --version command line option

* Corrected parsing of -v and --version

* Review corrections
  • Loading branch information
pickworthi authored Nov 13, 2024
1 parent 223cd9e commit 24fd507
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+)")
)
Expand All @@ -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})",

Check failure on line 90 in umu/umu_run.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (W291)

umu/umu_run.py:90:67: W291 Trailing whitespace

Check failure on line 90 in umu/umu_run.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (W291)

umu/umu_run.py:90:67: W291 Trailing whitespace
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:]:
Expand Down

0 comments on commit 24fd507

Please sign in to comment.