Say my CLI utility has three commands: cmd1
, cmd2
, cmd3
And I want cmd3
to have same options and flags as cmd1
and cmd2
. Like some sort of inheritance.
@click.command()
@click.options("--verbose")
def cmd1():
pass
@click.command()
@click.options("--directory")
def cmd2():
pass
@click.command()
@click.inherit(cmd1, cmd2) # HYPOTHETICAL
def cmd3():
pass
So cmd3
will have flag --verbose
and option --directory
. Is it possible to make this with Click? Maybe I just have overlooked something in the documentation...
EDIT: I know that I can do this with click.group()
. But then all the group's options must be specified before group's command. I want to have all the options normally after command.
cli.py --verbose --directory /tmp cmd3
-> cli.py cmd3 --verbose --directory /tmp