webapp.py 1.5 KB

123456789101112131415161718192021222324252627
  1. """``hermes webapp``: open the Desktop workspace in a browser, served by the gateway."""
  2. from __future__ import annotations
  3. from typing import Callable
  4. def build_webapp_parser(subparsers, *, cmd_webapp: Callable) -> None:
  5. parser = subparsers.add_parser(
  6. "webapp",
  7. help="Open the Hermes Desktop workspace in a browser",
  8. description=(
  9. "Open the Hermes Desktop workspace in a browser. The gateway serves it when "
  10. "webapp.enabled is true in config.yaml; this command builds the bundle when needed, "
  11. "starts the gateway and opens a one-use sign-in link."
  12. ),
  13. )
  14. parser.add_argument("--no-open", action="store_true", help="Print the one-use link instead of opening a browser")
  15. parser.add_argument("--force-build", action="store_true",
  16. help="Rebuild the Webapp bundle even when its build receipt is current")
  17. parser.add_argument("--skip-build", action="store_true", help="Use the existing Webapp bundle as is")
  18. action = parser.add_mutually_exclusive_group()
  19. action.add_argument("--build-only", action="store_true", help="Build the Webapp bundle and stop")
  20. action.add_argument("--status", action="store_true", help="Show whether the gateway is serving the Webapp")
  21. action.add_argument("--sign-out", action="store_true",
  22. help="Sign out every Webapp tab (each needs a new link from hermes webapp)")
  23. parser.set_defaults(func=cmd_webapp)