click is a Python package for creating beautiful command line interfaces in a composable way with as little amount of code as necessary. It’s the “Command Line Interface Creation Kit”.
import click
@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)
if __name__ == '__main__':
hello()
python click_test.py --help
Usage: click_test.py [OPTIONS] NAME
Options:
--count=COUNT number of greetings
--help Show this message and exit.
No comments:
Post a Comment