Last active
August 29, 2015 14:01
-
-
Save lidi/d8d9dee41f9029bb5140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompt_test = True | |
@click.group() | |
@click.option('--mode', is_flag=True) | |
def cli(mode): | |
prompt_test = True if mode else False | |
print "prompt_test value in cli: %s" % prompt_test | |
@cli.command() | |
@click.option('--name', | |
prompt=prompt_test, | |
required=True | |
) | |
def test(name): | |
print "prompt_test value in test: %s" % prompt_test | |
print "test %s" % name | |
if __name__ == '__main__': | |
cli() | |
# Ok | |
# $ python __test_click --mode test | |
# prompt_test value in cli: True | |
# Name: aaa | |
# prompt_test value in test: True | |
# test aaa | |
# Not ok | |
# $ python __test_click.py test | |
# prompt_test value in cli: False <-- Looks good! | |
# Name: aaa <-- Unexpected prompting? | |
# prompt_test value in test: True <-- Why? | |
# test aaa | |
# Not ok | |
# $ python __test_click.py test --name aaa | |
# prompt_test value in cli: False <-- Ok | |
# prompt_test value in test: True <-- Why? | |
# test aaa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment