Created
February 6, 2022 15:01
-
-
Save MartinThoma/e49d65aa3f953b7fe3edb2d0d08a4401 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 typer | |
from pathlib import Path | |
app = typer.Typer(help="Awesome app doing awesome things.", add_completion=False) | |
@app.command() | |
def spread(name: str, count: int = typer.Option(1, help="How much love you want")): | |
"""Spread the love.""" | |
for i in range(count): | |
print(f"{name} loves you ❤️") | |
@app.command(name="print") | |
def print_(filepath: Path = typer.Option(..., exists=True), show_meta: bool = False): | |
"""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