4 ms·
You're never forced to use decorators, they're just syntactic sugar. Their example: @click.command() @click.option('--count', default=1, help='number of g
by icebraining 13y ago
You're never forced to use decorators, they're just syntactic sugar.
Their example:
@click.command()
@click.option('--count', default=1, help='number of greetings')
@click.option('--name', prompt='Your name',
help='the person to greet', required=True)
def hello(count, name):
for x in range(count):
print('Hello %s!' % name)
Could be written as:
def hello(count, name):
for x in range(count):
print('Hello %s!' % name
hello = click.option('--name', prompt='Your name',
help='the person to greet', required=True)(hello)
hello = click.option('--count', default=1, help='number of greetings')(hello)
hello = click.command(hello)
- u124556 13y agoThe command decorator is nice, but the group decorator feels wrong, why create a function that does nothing just to decorate it? I'd rather use `cli = click.Group()`.