Skip to content

Instantly share code, notes, and snippets.

@Astro-Lee
Last active July 27, 2024 16:39
Show Gist options
  • Select an option

  • Save Astro-Lee/dffc773fbcb5e0fb33ff175f2c213c43 to your computer and use it in GitHub Desktop.

Select an option

Save Astro-Lee/dffc773fbcb5e0fb33ff175f2c213c43 to your computer and use it in GitHub Desktop.
click for CLI
#!/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