diff --git a/pyaptly/cli.py b/pyaptly/cli.py index 1271394..4e3068e 100644 --- a/pyaptly/cli.py +++ b/pyaptly/cli.py @@ -1,4 +1,5 @@ """python-click based command line interface for pyaptly.""" +import sys from pathlib import Path import click @@ -7,6 +8,18 @@ # do this in a few other CLIs for startup performance. +# TODO this makes the legacy command more usable. remove and set the entry point +# back to `pyaptly = 'pyaptly.cli:cli' +def entry_point(): + """Fix args then call click.""" + argv = list(sys.argv) + len_argv = len(argv) + if len_argv > 0 and argv[0].endswith("pyaptly"): + if len_argv > 2 and argv[1] == "legacy" and argv[2] != "--": + argv = argv[:2] + ["--"] + argv[2:] + cli.main(argv[1:]) + + @click.group() @click.option( "-d/-nd", @@ -22,6 +35,8 @@ def cli(debug: bool): util._DEBUG = debug +# TODO legacy is here to be able to do early alpha and get feedback from users. +# remove when there is full replacement. @cli.command(help="run legacy command parser") @click.argument("passthrough", nargs=-1) def legacy(passthrough): diff --git a/pyproject.toml b/pyproject.toml index 2c78719..1bbf30c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ check_untyped_defs = true profile = "black" [tool.poetry.scripts] -pyaptly = 'pyaptly.cli:cli' +pyaptly = 'pyaptly.cli:entry_point' [tool.flake8] ignore = [