-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclicker.py
49 lines (41 loc) · 1.04 KB
/
clicker.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from typing import Annotated
import typer
app = typer.Typer()
@app.command(name="mula")
def start2(
name: Annotated[str, typer.Argument()] = "default name",
number: Annotated[int, typer.Argument()] = 12,
db_path2: Annotated[
str,
typer.Option(),
] = "default_db_path",
) -> None:
"""Initialize the to-do database."""
typer.secho(f"starter2 {name=} {number=} db_path: {db_path2}")
if name == "error":
typer.secho(
f"Error",
fg=typer.colors.RED,
)
raise typer.Exit(1)
@app.command()
def start(
# argument
argument: str = typer.Argument(...),
db_path: str = typer.Option(
"db_path_string",
"--db-path",
"-db",
),
) -> None:
"""Initialize the to-do database."""
typer.secho(f"init {argument=} db_path: {db_path}")
if argument == "error":
typer.secho(
f"Error",
fg=typer.colors.RED,
)
raise typer.Exit(1)
if __name__ == "__main__":
print("Running typer app")
app()