- Click has
--help
but not-h
by default like argparse but can be customized per command or also for a group - Click how do you get the defaults in the help? Typer shows them by default.
Create a group called main
:
@click.group()
@click.option("--ssid", help="WiFi network name.")
@click.option("--security", type=click.Choice(["WEP", "WPA", ""]))
@click.option("--password", help="WiFi password.")
@click.pass_context
def main(ctx, ssid: str, security: str = "", password: str = ""):
qr = wifi_qr(ssid=ssid, security=security, password=password)
ctx.obj["qr"] = qr
Create child commands of the group main
that receive the group's context:
@main.command()
@click.pass_context
def terminal(ctx):
"""Print QR code to the terminal."""
print(ctx.obj["qr"].terminal())
Typer supports help for CLI arguments Configuration is via defaults rather than decorators which is nicer because everything is together, but it means if you call a typer command function from another function the caller has to specify all values