mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Document GUI backend requirement and handle missing backend
This commit is contained in:
@@ -24,6 +24,7 @@ import uvicorn
|
||||
from . import api as api_module
|
||||
|
||||
import importlib
|
||||
import importlib.util
|
||||
|
||||
app = typer.Typer(
|
||||
help="SeedPass command line interface",
|
||||
@@ -95,6 +96,14 @@ def _get_nostr_service(ctx: typer.Context) -> NostrService:
|
||||
return NostrService(pm)
|
||||
|
||||
|
||||
def _gui_backend_available() -> bool:
|
||||
"""Return True if a platform-specific BeeWare backend is installed."""
|
||||
for pkg in ("toga_gtk", "toga_winforms", "toga_cocoa"):
|
||||
if importlib.util.find_spec(pkg) is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@app.callback(invoke_without_command=True)
|
||||
def main(ctx: typer.Context, fingerprint: Optional[str] = fingerprint_option) -> None:
|
||||
"""SeedPass CLI entry point.
|
||||
@@ -740,6 +749,14 @@ def api_stop(ctx: typer.Context, host: str = "127.0.0.1", port: int = 8000) -> N
|
||||
@app.command()
|
||||
def gui() -> None:
|
||||
"""Launch the BeeWare GUI."""
|
||||
if not _gui_backend_available():
|
||||
typer.echo(
|
||||
"No BeeWare GUI backend found. Install 'toga-gtk' (Linux), "
|
||||
"'toga-winforms' (Windows) or 'toga-cocoa' (macOS) to run the GUI.",
|
||||
err=True,
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
|
||||
from seedpass_gui.app import main
|
||||
|
||||
main()
|
||||
|
Reference in New Issue
Block a user