-
First Check
Commit to Help
Example Codeimport click
@click.command(context_settings={"ignore_unknown_options": True, "help_option_names": []})
@click.argument("command", nargs=-1, type=click.UNPROCESSED)
def compose(command: list[str]) -> None:
"""Execute docker compose command."""
print(command) DescriptionThe code above shows how I can create a command that consumes arbitrary arguments and options with I didn't figure out how to achieve the same behavior with cli = typer.main.get_command(app)
cli.add_command(compose, "compose") But I was wondering whether there is some pure Operating SystemLinux Operating System DetailsNo response Typer Version0.15.2 Python VersionPython 3.12.8 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry for this. I did search the documentation, I swear. After several hours I posted the question. An then after 10 minutes I found the solution right there in the docs: https://typer.tiangolo.com/tutorial/commands/context/?h=#configuring-the-context import typer
app = typer.Typer()
@app.command(context_settings={"allow_extra_args": True, "ignore_unknown_options": True})
def compose(ctx: typer.Context):
print(ctx.args) |
Beta Was this translation helpful? Give feedback.
Sorry for this. I did search the documentation, I swear. After several hours I posted the question. An then after 10 minutes I found the solution right there in the docs: https://typer.tiangolo.com/tutorial/commands/context/?h=#configuring-the-context