diff --git a/bin/gniza b/bin/gniza index 9c905ca..8a16779 100755 --- a/bin/gniza +++ b/bin/gniza @@ -431,7 +431,10 @@ run_cli() { } # ── Mode selection ─────────────────────────────────────────── -if [[ -n "$SUBCOMMAND" ]]; then +if [[ "$SUBCOMMAND" == "web" || " $* " == *" --web "* ]]; then + # Web GUI mode + PYTHONPATH="$GNIZA_DIR:${PYTHONPATH:-}" exec python3 -m tui --web "$@" +elif [[ -n "$SUBCOMMAND" ]]; then # Explicit subcommand: always CLI run_cli elif [[ "$FORCE_CLI" == "true" ]]; then diff --git a/tui/__main__.py b/tui/__main__.py index 25c13d5..aa65d7d 100644 --- a/tui/__main__.py +++ b/tui/__main__.py @@ -1,9 +1,20 @@ +import sys + from tui.app import GnizaApp def main(): - app = GnizaApp() - app.run() + if "--web" in sys.argv: + from textual_serve.server import Server + port = 8080 + for i, arg in enumerate(sys.argv): + if arg == "--port" and i + 1 < len(sys.argv): + port = int(sys.argv[i + 1]) + server = Server("python3 -m tui", host="0.0.0.0", port=port) + server.serve() + else: + app = GnizaApp() + app.run() if __name__ == "__main__":