connectors.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """``hermes connectors`` subcommand parser."""
  2. from __future__ import annotations
  3. def build_connectors_parser(subparsers) -> None:
  4. """Attach the ``connectors`` subcommand to ``subparsers``."""
  5. from hermes_cli.connectors_cmd import cmd_connectors
  6. parser = subparsers.add_parser(
  7. "connectors", help="Manage hosted app connectors and their accounts",
  8. description="List, connect, rename and remove the app accounts Hermes uses through Nous Portal.")
  9. actions = parser.add_subparsers(dest="connectors_action")
  10. actions.add_parser("list", aliases=["ls"], help="Show every connector and whether it is connected")
  11. accounts = actions.add_parser("accounts", help="Show connected accounts")
  12. accounts.add_argument("app", nargs="?", help="Only show accounts of this app")
  13. accounts.add_argument("--all", action="store_true", help="Also show retired accounts")
  14. connect = actions.add_parser("connect", help="Connect an app account in your browser")
  15. connect.add_argument("app", help="App to connect, for example gmail")
  16. connect.add_argument(
  17. "--alias", help="Name for a new account (for example work); with --reconnect, the name or label to repair")
  18. connect.add_argument("--reconnect", action="store_true", help="Repair an account that stopped working")
  19. connect.add_argument(
  20. "--force", action="store_true", help="With --reconnect, sign in again even if the account is connected")
  21. rename = actions.add_parser("rename", help="Rename an account")
  22. rename.add_argument("app", help="App the account belongs to")
  23. rename.add_argument("name", help="Current name or label of the account")
  24. rename.add_argument("--to", required=True, help="New name for the account")
  25. disconnect = actions.add_parser("disconnect", help="Remove an account")
  26. disconnect.add_argument("app", help="App the account belongs to")
  27. disconnect.add_argument("--alias", help="Name or label of the account to remove")
  28. disconnect.add_argument("--yes", "-y", action="store_true", help="Skip the confirmation prompt")
  29. parser.set_defaults(func=cmd_connectors)