Running the following code as python script.py
does nothing,I expect at least the click.echo statement to get printed, sounds like the call to first_command doesn't work, any idea why?
import click
def multiple_input_option(**option_kwargs):
def decorator(func):
def _callback(ctx, param, value):
ctx.obj['multiple_options'] = value
help_text = 'some options to get from user'
keyword_arguments = {
'help': help_text,
'callback': _callback,
'expose_value': False,
'multiple': True,
}
keyword_arguments.update(**option_kwargs)
return click.option('--multiple-options', '-e', **keyword_arguments)(func)
return decorator
@click.command()
@multiple_input_option()
def first_command(ctx):
click.echo('> hello...first_command')
command_param_data = ctx.obj.keys()
click.echo(json.dumps(command_param_data, indent=2))
@click.group()
def hello_world(ctx):
"""
Your plugin description here
"""
ctx.ensure_object(dict)
# This is how we add more sub-commands
hello_world.add_command(first_command)
from Why is the click add_command not working?
No comments:
Post a Comment