click icon indicating copy to clipboard operation
click copied to clipboard

Adding extra option to click.CommandCollection ?

Open yspanchal opened this issue 9 years ago • 6 comments

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

yspanchal avatar May 12 '15 15:05 yspanchal

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 avatar May 13 '15 11:05 untitaker

@untitaker thank you... its done...!!! :)

yspanchal avatar May 13 '15 15:05 yspanchal

I'll leave this open because the docs should explain this.

untitaker avatar May 14 '15 17:05 untitaker

:+1:

lordnynex avatar Nov 19 '15 07:11 lordnynex

Does it make sense to document it given #347 ?

mindw avatar Feb 28 '17 13:02 mindw

This should be documented after a fix is implemented in https://github.com/pallets/click/issues/347.

jcrotts avatar May 15 '18 16:05 jcrotts