gitea.cli.utils
utils
Utility functions for Gitea CLI.
Functions:
gitea.cli.utils.execute_api_command
execute_api_command(
api_call: Callable[
[],
tuple[
dict[str, Any] | list[dict[str, Any]],
dict[str, Any],
],
],
command_name: str = "Command",
base_url: str | None = None,
) -> None
Execute an API command and print the result as the JSON envelope.
The result is always written as the {"data": ..., "metadata": ...} JSON
envelope, so these commands already satisfy --output json and are
unaffected by --output text. A command with a human-readable rendering of
its own calls execute_api_call instead, and reports the result itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_call
|
Callable[[], tuple[dict[str, Any] | list[dict[str, Any]], dict[str, Any]]]
|
Callable that executes the API call and returns the result. |
required |
command_name
|
str
|
Name of the command for error messages. |
'Command'
|
base_url
|
str | None
|
The base URL the call is made against, so an unreachable instance is reported by the host the command tried to reach. The callable holds the client, so the host is not recoverable from here and every command is expected to pass it. |
None
|
Source code in src/gitea/cli/utils/api.py
gitea.cli.utils.get_auth_params
get_auth_params(
config_path: Path | str,
account_name: str | None,
token: str | None,
base_url: str | None,
) -> tuple[str, str]
Get authentication parameters from CLI context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path | str
|
Path to the configuration file. |
required |
account_name
|
str | None
|
Name of the account to use for authentication. |
required |
token
|
str | None
|
Token for authentication. |
required |
base_url
|
str | None
|
Base URL of the Gitea platform. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
A tuple containing the token and base URL for authentication. |