Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, there is a package called typer-click that allows you to build command line interfaces with Typer using Click-style commands and options.

You can install this package using pip:

pip install typer-click

And then you can use it to define commands and options in your Typer app:

import typer
import typer_click as click

app = typer.Typer()

@app.command()
@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', prompt='Your name', help='The person to greet.')
def hello(count, name):
    """Simple program that greets NAME for a total of COUNT times."""
    for _ in range(count):
        typer.echo(f'Hello, {name}!')

if __name__ == '__main__':
    app()

This example defines a hello command with count and name options that are handled by Click. You can still use Typer's features, such as prompts and type annotations, alongside the Click options.

You can find more information and examples in the typer-click documentation: https://typer-click.readthedocs.io/en/latest/