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

Missing command error when providing only group options #17

Open
edobez opened this issue May 8, 2021 · 2 comments
Open

Missing command error when providing only group options #17

edobez opened this issue May 8, 2021 · 2 comments

Comments

@edobez
Copy link

edobez commented May 8, 2021

As title says, a missing command error is shown when only group options are passed to the prompt.

The expected behavior is that group options are handled by the group and then default command is invoked.

Minimum example

import click
from click_default_group import DefaultGroup

@click.group(cls=DefaultGroup, default='foo', default_if_no_args=True)
@click.option('-v', is_flag=True)
def cli(v):
    print('cli group exec')
    if v:
        print('Verbose!')

@cli.command()
@click.option('--config')
def foo(config):
    print('foo command exec')
    if config:
        print(f'config={config}')

Execution

$ program foo                           
--> normal call, works

$ program
--> default cmd is called, works

$ program --config=abc 
--> option is forwarded to 'foo' cmd, works

$ program -v --config=abc
--> '-v' option is parsed by group and '--config' is parsed by 'foo' cmd, works

$ program -v
--> doesn't work!
edobez pushed a commit to edobez/click-default-group that referenced this issue May 8, 2021
edobez pushed a commit to edobez/click-default-group that referenced this issue May 8, 2021
@edobez
Copy link
Author

edobez commented May 8, 2021

I forked and created a branch with (refactored) tests covering this behavior.
I looked a bit into it but didn't find a proper solution yet.

pyhedgehog added a commit to pyhedgehog/click-default-group that referenced this issue Oct 27, 2022
pyhedgehog added a commit to pyhedgehog/click-default-group that referenced this issue Oct 27, 2022
@pyhedgehog
Copy link

I've pushed fix #23. Hope this patch is in line with plans of author. @sublee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants