gamesheet_sdk.common.cli.helpers module

CLI helper functions shared across command modules.

gamesheet_sdk.common.cli.helpers.run_action_or_exit(session, action, *args, **kwargs)[source]

Run an action function with error handling.

Wraps the action call in the session’s context manager and catches AuthenticationError and GameSheetError. On either exception, prints a user-friendly error message to stderr and exits with code 1. The session context manager ensures proper cleanup (e.g., closing connections) regardless of success or failure.

Parameters:
  • session (BaseAuthenticatedSession) – The authenticated session to use as a context manager.

  • action (Callable[..., _R]) – A callable that takes session and *args and returns a result. Typically a domain action function (e.g., list_associations).

  • *args (object) – Positional arguments forwarded to action after session.

  • **kwargs (object) – Keyword arguments forwarded to action.

Returns:

_R – The result of action(session, *args, **kwargs) on success.

Raises:

Exit – If action raises AuthenticationError or GameSheetError. Exit code is 1 in both cases.

Return type:

_R

gamesheet_sdk.common.cli.helpers.emit_shell_completion(shell, prog_name, complete_var)[source]

Emit shell completion script for the specified shell.

Parameters:
  • shell (str) – Target shell (bash, zsh, or fish).

  • prog_name (str) – The CLI program name.

  • complete_var (str) – Environment variable name for completion.

Raises:

Exit – If the specified shell is unsupported.