forked from The-DevOps-Daily/devops-daily
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
29 lines (21 loc) · 635 Bytes
/
hello.py
File metadata and controls
29 lines (21 loc) · 635 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import typer
from state import set_verbose, verbose_active
app = typer.Typer(help="Hello command group")
@app.command()
def greet(
ctx: typer.Context,
name: str = typer.Option("World", "--name", "-n", help="Name to greet."),
verbose: bool = typer.Option(
False,
"--verbose",
"-v",
is_flag=True,
help="Enable verbose output for this command.",
),
) -> None:
"""Say hello to someone."""
if verbose:
set_verbose(ctx, True)
if verbose_active(ctx):
typer.echo(f"[verbose] Preparing greeting for {name}", err=True)
typer.echo(f"Hello, {name}!")