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

Calling commands from commands is broken #46

Closed
schlamar opened this issue Apr 30, 2014 · 1 comment
Closed

Calling commands from commands is broken #46

schlamar opened this issue Apr 30, 2014 · 1 comment

Comments

@schlamar
Copy link
Contributor

I would expect that something like the following works:

import click

cli = click.Group()

@cli.command()
@click.option('--count', default=1)
def test(count):
    print 'test', count

@cli.command()
@click.option('--count', default=1)
def dist(count):
    test()

if __name__ == '__main__':
    cli()

But this fails with

$ py cli.py dist
Usage: cli.py [OPTIONS]

Error: Got unexpected extra argument (dist)
@mitsuhiko
Copy link
Contributor

The only way to make this work (without introducing magic global state) is through a method on the context. This is already supported through context.invoke but I added extra support for making it nicer and added it to the docs.

http://click.pocoo.org/advanced/#invoking-other-commands

@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