Click v7.0
I'm trying to write a wrapper for git for my own purposes. I'm new to using click, so correct me if I'm doing this the wrong way.
My goal is to have special sub commands do specific functionalities, and if the argument is not a special sub command, default to running git with the given arguments.
I have something like this
import click
@click.group(
invoke_without_command=True,
context_settings = {'ignore_unknown_options': True, 'allow_extra_args': True}
)
@click.pass_context
def cli(ctx):
if not ctx.invoked_subcommand:
# run git with given arguments instead
...
@cli.command()
def special_command():
# do some special functionality
What I want is when I run the cli with arguments/commands that isn't the special command, to run git with those arguments. But the cli gives me a Error: No such command ... if I give it any command other than the special command. Is this possible? Or am I doing this the wrong way?
I also want to add that I'm running this through setuptools and the entry point is cli
Example: My git wrapper is called cli
cli special_command will run the special command
cli status will run git status
Click v7.0
I'm trying to write a wrapper for git for my own purposes. I'm new to using click, so correct me if I'm doing this the wrong way.
My goal is to have special sub commands do specific functionalities, and if the argument is not a special sub command, default to running git with the given arguments.
I have something like this
What I want is when I run the cli with arguments/commands that isn't the special command, to run git with those arguments. But the cli gives me a
Error: No such command ...if I give it any command other than the special command. Is this possible? Or am I doing this the wrong way?I also want to add that I'm running this through setuptools and the entry point is
cliExample: My git wrapper is called
clicli special_commandwill run the special commandcli statuswill rungit status