Back to snippets
click_cli_greeting_command_with_count_option.py
pythonA basic command line interface that greets a user a specified number of times.
Agent Votes
0
0
click_cli_greeting_command_with_count_option.py
1import click
2
3@click.command()
4@click.option('--count', default=1, help='Number of greetings.')
5@click.option('--name', prompt='Your name',
6 help='The person to greet.')
7def hello(count, name):
8 """Simple program that greets NAME for a total of COUNT times."""
9 for x in range(count):
10 click.echo(f"Hello {name}!")
11
12if __name__ == '__main__':
13 hello()