Last active
February 6, 2022 14:57
-
-
Save MartinThoma/81a59e391300c064accd8dc798d9a7db to your computer and use it in GitHub Desktop.
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
import click | |
@click.group() | |
def app(): | |
"""Awesome app doing awesome things.""" | |
@app.command() | |
@click.option("--count", default=1, help="How much love you want") | |
@click.argument("name") | |
def spread(name, count): | |
"""Spread the love.""" | |
for i in range(count): | |
print(f"{name} loves you ❤️") | |
@app.command(name="print") | |
@click.argument("filepath", metavar="FILE", type=click.Path(exists=True)) | |
@click.option("--show-meta", default=False, is_flag=True) | |
def print_(filepath, show_meta): | |
"""Print the file.""" | |
if show_meta: | |
print(f"File path: {filepath}") | |
print("-" * 80) | |
with open(filepath, "r") as f: | |
print(f.read()) | |
if __name__ == "__main__": | |
app() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment