mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Merge pull request #718 from PR0M3TH3AN/codex/replace-auto-install-logic-in-cli.gui
feat(cli): require manual GUI backend install
This commit is contained in:
@@ -834,11 +834,18 @@ def api_stop(ctx: typer.Context, host: str = "127.0.0.1", port: int = 8000) -> N
|
|||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def gui() -> None:
|
def gui(
|
||||||
|
install: bool = typer.Option(
|
||||||
|
False,
|
||||||
|
"--install",
|
||||||
|
help="Attempt to install the BeeWare GUI backend if missing",
|
||||||
|
)
|
||||||
|
) -> None:
|
||||||
"""Launch the BeeWare GUI.
|
"""Launch the BeeWare GUI.
|
||||||
|
|
||||||
If the platform specific backend is missing, attempt to install it and
|
If a platform specific backend is missing, inform the user how to
|
||||||
retry launching the GUI.
|
install it. Using ``--install`` will attempt installation after
|
||||||
|
confirmation.
|
||||||
"""
|
"""
|
||||||
if not _gui_backend_available():
|
if not _gui_backend_available():
|
||||||
if sys.platform.startswith("linux"):
|
if sys.platform.startswith("linux"):
|
||||||
@@ -854,7 +861,18 @@ def gui() -> None:
|
|||||||
)
|
)
|
||||||
raise typer.Exit(1)
|
raise typer.Exit(1)
|
||||||
|
|
||||||
typer.echo(f"Attempting to install {pkg} for GUI support...")
|
if not install:
|
||||||
|
typer.echo(
|
||||||
|
f"BeeWare GUI backend not found. Please install {pkg} "
|
||||||
|
"manually or rerun with '--install'.",
|
||||||
|
err=True,
|
||||||
|
)
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
|
if not typer.confirm(f"Install {pkg} using pip?", default=False):
|
||||||
|
typer.echo("Installation cancelled.", err=True)
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg])
|
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg])
|
||||||
typer.echo(f"Successfully installed {pkg}.")
|
typer.echo(f"Successfully installed {pkg}.")
|
||||||
|
@@ -629,7 +629,17 @@ def test_gui_command(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_gui_command_no_backend(monkeypatch):
|
def test_gui_command_no_backend(monkeypatch):
|
||||||
"""Install backend if missing and launch GUI."""
|
"""Exit with message when backend is missing."""
|
||||||
|
|
||||||
|
monkeypatch.setattr(cli, "_gui_backend_available", lambda: False)
|
||||||
|
|
||||||
|
result = runner.invoke(app, ["gui"])
|
||||||
|
assert result.exit_code == 1
|
||||||
|
assert "Please install" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_gui_command_install_backend(monkeypatch):
|
||||||
|
"""Install backend on request and launch GUI."""
|
||||||
|
|
||||||
call_count = {"n": 0}
|
call_count = {"n": 0}
|
||||||
|
|
||||||
@@ -657,7 +667,7 @@ def test_gui_command_no_backend(monkeypatch):
|
|||||||
SimpleNamespace(main=fake_main),
|
SimpleNamespace(main=fake_main),
|
||||||
)
|
)
|
||||||
|
|
||||||
result = runner.invoke(app, ["gui"])
|
result = runner.invoke(app, ["gui", "--install"], input="y\n")
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert installed.get("cmd") is not None
|
assert installed.get("cmd") is not None
|
||||||
assert called.get("gui") is True
|
assert called.get("gui") is True
|
||||||
|
Reference in New Issue
Block a user