()
| 17 | |
| 18 | |
| 19 | def parse_args() -> Namespace | tuple[str, list[str]]: # noqa: D103 |
| 20 | opt_args: set[str] = {"--help", "-h", "--config", "--version", "-v"} |
| 21 | parser: ArgumentParser = ArgumentParser( |
| 22 | description="Unified Linux Wine Game Launcher", |
| 23 | epilog=( |
| 24 | "See umu(1) for more info and examples, or visit\n" |
| 25 | "https://github.com/Open-Wine-Components/umu-launcher" |
| 26 | ), |
| 27 | formatter_class=RawTextHelpFormatter, |
| 28 | ) |
| 29 | parser.add_argument( |
| 30 | "-v", |
| 31 | "--version", |
| 32 | action="version", |
| 33 | version=f"umu-launcher version {__version__} ({sys.version})", |
| 34 | help="show this version and exit", |
| 35 | ) |
| 36 | parser.add_argument("--config", help=("path to TOML file (requires Python 3.11+)")) |
| 37 | parser.add_argument( |
| 38 | "winetricks", |
| 39 | help=("run winetricks verbs (requires UMU-Proton or GE-Proton)"), |
| 40 | nargs="?", |
| 41 | default=None, |
| 42 | ) |
| 43 | |
| 44 | if not sys.argv[1:]: |
| 45 | parser.print_help(sys.stderr) |
| 46 | sys.exit(1) |
| 47 | |
| 48 | # Winetricks |
| 49 | # Exit if no winetricks verbs were passed |
| 50 | if sys.argv[1].endswith("winetricks") and not sys.argv[2:]: |
| 51 | err: str = "No winetricks verb specified" |
| 52 | log.error(err) |
| 53 | sys.exit(1) |
| 54 | |
| 55 | # Exit if argument is not a verb |
| 56 | if sys.argv[1].endswith("winetricks") and not is_winetricks_verb(sys.argv[2:]): |
| 57 | sys.exit(1) |
| 58 | |
| 59 | if sys.argv[1:][0] in opt_args: |
| 60 | return parser.parse_args(sys.argv[1:]) |
| 61 | |
| 62 | if sys.argv[1] in PROTON_VERBS: |
| 63 | if "PROTON_VERB" not in os.environ: |
| 64 | os.environ["PROTON_VERB"] = sys.argv[1] |
| 65 | sys.argv.pop(1) |
| 66 | |
| 67 | return sys.argv[1], sys.argv[2:] |
| 68 | |
| 69 | |
| 70 | def main() -> int: # noqa: D103 |
no test coverage detected