2022-12-19 23:22:23 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
It can be convenient to quickly generate a cli for a short script.
|
|
|
|
Or to add simple visualization of data using the wonderful rich library.
|
|
|
|
"""
|
|
|
|
|
2023-03-15 13:16:09 -05:00
|
|
|
__import__("viv").use("typer", "rich-click") # noqa
|
2022-12-19 23:22:23 -06:00
|
|
|
|
|
|
|
import typer
|
|
|
|
|
2022-12-20 13:29:15 -06:00
|
|
|
app = typer.Typer(add_completion=False)
|
2022-12-19 23:22:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
def hello(name: str):
|
|
|
|
print(f"Hello {name}")
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
def goodbye(name: str, formal: bool = False):
|
2022-12-20 14:15:17 -06:00
|
|
|
print(f"Bye {name}")
|
2022-12-19 23:22:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app()
|