click
click copied to clipboard
Adding extra option to click.CommandCollection ?
Hi,
I want to add extra option to click.CommandCollection.
cli = click.CommandCollection(sources=[account, user], context_settings=CONTEXT_SETTINGS)
if __name__ == __main__:
cli()
i want to add --xyz option to cli command
cli --xyz
import click
@click.group()
def cli1():
pass
@cli1.command()
def cmd1():
"""Command on cli1"""
@click.group()
def cli2(foo):
pass
@cli2.command()
def cmd2():
"""Command on cli2"""
@click.command(cls=click.CommandCollection, sources=[cli1, cli2])
@click.option('--foo')
def cli(foo):
pass
if __name__ == '__main__':
cli()
I think this should be added to the docs, not sure if it works completely as expected though.
@untitaker thank you... its done...!!! :)
I'll leave this open because the docs should explain this.
:+1:
Does it make sense to document it given #347 ?
This should be documented after a fix is implemented in https://github.com/pallets/click/issues/347.