login.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """``hermes login`` subcommand parser."""
  2. from __future__ import annotations
  3. from typing import Callable
  4. def build_login_parser(subparsers, *, cmd_login: Callable) -> None:
  5. """Attach the deprecated ``login`` subcommand (handler only prints a deprecation notice).
  6. Kept registered so old scripts get the actionable message instead of argparse's
  7. ``invalid choice``. Registered WITHOUT ``help=`` so it is omitted from ``hermes --help``
  8. (``help=SUPPRESS`` leaks ``==SUPPRESS==`` for top-level subparsers on 3.12+). ``--provider``
  9. takes ANY value (no ``choices=``) so the handler is reached rather than argparse erroring.
  10. This hides a command that no longer works (#24756) without the ``help=argparse.SUPPRESS``
  11. ``==SUPPRESS==`` leak that argparse emits for a top-level subparser on Python 3.12+.
  12. """
  13. login_parser = subparsers.add_parser(
  14. "login",
  15. description="Deprecated. Use `hermes auth` to manage credentials, "
  16. "`hermes model` to select a provider, or `hermes setup` for full setup.")
  17. # No ``choices=`` on purpose — the handler is a deprecation notice that
  18. # ignores the value, and a restrictive list would reject providers the user
  19. # legitimately wants (e.g. ``anthropic``) with an argparse error before the
  20. # friendly redirect message is ever printed.
  21. login_parser.add_argument(
  22. "--provider", default=None, help="(deprecated) Provider name; ignored — see `hermes model`")
  23. login_parser.add_argument("--portal-url", help="Portal base URL (default: production portal)")
  24. login_parser.add_argument(
  25. "--inference-url", help="Inference API base URL (default: production inference API)")
  26. login_parser.add_argument(
  27. "--client-id", default=None, help="OAuth client id to use (default: hermes-cli)")
  28. login_parser.add_argument("--scope", default=None, help="OAuth scope to request")
  29. login_parser.add_argument(
  30. "--no-browser", action="store_true",
  31. help="Do not attempt to open the browser automatically")
  32. login_parser.add_argument(
  33. "--timeout", type=float, default=15.0, help="HTTP request timeout in seconds (default: 15)")
  34. login_parser.add_argument("--ca-bundle", help="Path to CA bundle PEM file for TLS verification")
  35. login_parser.add_argument(
  36. "--insecure", action="store_true", help="Disable TLS verification (testing only)")
  37. login_parser.set_defaults(func=cmd_login)