Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command collection with multiple different options on the groups? #1032

Closed
silky opened this issue Jun 4, 2018 · 1 comment
Closed

command collection with multiple different options on the groups? #1032

silky opened this issue Jun 4, 2018 · 1 comment

Comments

@silky
Copy link

silky commented Jun 4, 2018

consider the following example:

#!/usr/bin/env python

import click

@click.group()
@click.option("--c1", type=str, required=True)
def cli1(c1):
    pass

@cli1.command()
def cmd1():
    """Command on cli1"""
    print("cmd1")

@click.group()
@click.option("--c2", type=str, required=True)
def cli2(c2):
    pass

@cli2.command()
def cmd2():
    """Command on cli2"""
    print("cmd2")

cli = click.CommandCollection(sources=[cli1, cli2])

if __name__ == '__main__':
    cli()

the options get lost. there is no way to pass values to them.

how can i make this example work?

@davidism
Copy link
Member

davidism commented Jun 6, 2018

Duplicate of #347

See #341 for a workaround after creating the collection. I know a command's options are introspectable somehow, so you could manually pull the options off and put them back on the new collection as a workaround until the duplicate is addressed.

@davidism davidism closed this as completed Jun 6, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants