Last active
July 27, 2024 16:39
-
-
Save Astro-Lee/dffc773fbcb5e0fb33ff175f2c213c43 to your computer and use it in GitHub Desktop.
click for CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import click | |
| @click.command(context_settings=dict(help_option_names=['-h', '--help'])) | |
| @click.option('-c',"--count", default=1, help="Number of greetings.") | |
| @click.option('-n',"--name", prompt="Your name", help="The person to greet.") | |
| def hello(count, name): | |
| """Simple program that greets NAME for a total of COUNT times.""" | |
| for _ in range(count): | |
| click.echo(f"Hello, {name}!") | |
| if __name__ == '__main__': | |
| hello() | |
| click.secho('Hello World!', fg='green') | |
| click.secho('Some more text', bg='blue', fg='white') | |
| click.secho('ATTENTION', blink=True, bold=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment