mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-14 18:19:37 +00:00
Use custom SeedPassError instead of sys.exit
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Optional
|
||||
import typer
|
||||
|
||||
from .common import _get_services
|
||||
from seedpass.core.errors import SeedPassError
|
||||
|
||||
app = typer.Typer(
|
||||
help="SeedPass command line interface",
|
||||
@@ -49,6 +50,15 @@ app.add_typer(util.app, name="util")
|
||||
app.add_typer(api.app, name="api")
|
||||
|
||||
|
||||
def run() -> None:
|
||||
"""Invoke the CLI, handling SeedPass errors gracefully."""
|
||||
try:
|
||||
app()
|
||||
except SeedPassError as exc:
|
||||
typer.echo(str(exc), err=True)
|
||||
raise typer.Exit(1) from exc
|
||||
|
||||
|
||||
def _gui_backend_available() -> bool:
|
||||
"""Return True if a platform-specific BeeWare backend is installed."""
|
||||
for pkg in ("toga_gtk", "toga_winforms", "toga_cocoa"):
|
||||
@@ -173,4 +183,4 @@ def gui(
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
app()
|
||||
run()
|
||||
|
Reference in New Issue
Block a user