forked from The-DevOps-Daily/devops-daily
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
33 lines (25 loc) · 720 Bytes
/
cli.py
File metadata and controls
33 lines (25 loc) · 720 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
30
31
32
33
import typer
from commands import hello, listing
from state import set_verbose
# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")
@app.callback()
def main(
ctx: typer.Context,
verbose: bool = typer.Option(
False,
"--verbose",
"-v",
is_flag=True,
help="Enable verbose debug output for all commands.",
),
) -> None:
"""Configure application-wide options before subcommands run."""
set_verbose(ctx, verbose)
if verbose:
typer.echo("[verbose] Verbose mode enabled", err=True)
# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(listing.app, name="list")
if __name__ == "__main__":
app()