Skip to content

Commit

Permalink
Merge pull request #84 from adfinis/jlf/chore-improve-legacy-command-…
Browse files Browse the repository at this point in the history
…support

chore: improve legacy command support
  • Loading branch information
Jean-Louis Fuchs authored Mar 6, 2024
2 parents f2952b3 + bdfce0c commit 88ba5a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions pyaptly/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python-click based command line interface for pyaptly."""
import sys
from pathlib import Path

import click
Expand All @@ -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",
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 88ba5a1

Please sign in to comment.