Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve legacy command support #84

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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