pip install click_complete_fig
- You must pass in the root level CLI.
- The
add_completion_spec_command
function will add a newgenerate-fig-spec
to the passed incli
from click_complete_fig import fig
@click.group()
def cli():
pass
fig.add_completion_spec_command(cli)
NOTE: be sure to use
add_completion_spec_command
on a@click.group
wrapped function and not on a@click.command
wrapped one. Links: https://click.palletsprojects.com/en/8.0.x/commands/#commands-and-groups
You can now automatically generate the completion spec skeleton by running the following command:
$CLI generate-fig-spec > $CLI.ts
from click_complete_fig import fig
@click.command()
def cli():
pass
fig.generate_completion_spec(cli) # Will print the spec as long as the .py script is run
NOTE: this works both with
@click.group
and@click.command
wrapped functions.