Skip to content

Commit ea958aa

Browse files
committed
Only import trogon_tui when command is selected
1 parent 39bbc52 commit ea958aa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

nettowel/cli/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from nettowel.cli.pandas import app as pandas_app
2424
from nettowel.cli.help import get_qrcode, HELP_MARKDOWN
2525

26-
from nettowel.trogon_tui import run_trogon_tui
26+
from nettowel.exceptions import NettowelDependencyMissing
2727

2828
app = get_typer_app(help="Awesome collection of network automation functions")
2929

@@ -78,7 +78,13 @@ def help(
7878

7979
@app.command(help="Textual/Trogon TUI")
8080
def tui(ctx: typer.Context) -> None:
81-
run_trogon_tui(app=app, ctx=ctx)
81+
try:
82+
from nettowel.trogon_tui import run_trogon_tui
83+
84+
run_trogon_tui(app=app, ctx=ctx)
85+
except NettowelDependencyMissing as exc:
86+
typer.echo(str(exc), err=True)
87+
raise typer.Exit(1)
8288

8389

8490
def run() -> None:

0 commit comments

Comments
 (0)