| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from __future__ import print_function, absolute_import |
| 5 |
|
| 6 |
import click_completion |
| 7 |
|
| 8 |
import click |
| 9 |
|
| 10 |
import click_completion.core |
| 11 |
|
| 12 |
click_completion.init() |
| 13 |
|
| 14 |
|
| 15 |
def install_callback(ctx, attr, value): |
| 16 |
if not value or ctx.resilient_parsing: |
| 17 |
return value |
| 18 |
shell, path = click_completion.core.install() |
| 19 |
click.echo('%s completion installed in %s' % (shell, path)) |
| 20 |
exit(0) |
| 21 |
|
| 22 |
|
| 23 |
@click.command() |
| 24 |
@click.option('--install', is_flag=True, callback=install_callback, expose_value=False, |
| 25 |
help="Install completion for the current shell.") |
| 26 |
@click.option('--upper/--lower', default=None, help="Change text to upper or lower case") |
| 27 |
@click.argument('args', nargs=-1) |
| 28 |
def echo(upper, args): |
| 29 |
"""just print the command line arguments""" |
| 30 |
if upper: |
| 31 |
args = [arg.upper() for arg in args] |
| 32 |
elif upper is not None: |
| 33 |
args = [arg.lower() for arg in args] |
| 34 |
click.echo(' '.join(args)) |
| 35 |
|
| 36 |
|
| 37 |
if __name__ == "__main__": |
| 38 |
echo() |