gitea.cli.output
output
Utilities for selecting and rendering the CLI output format.
This lives outside gitea.cli.utils on purpose: main.py needs OutputFormat
at import time to declare the global --output option, and importing it from
gitea.cli.utils would pull that package's configuration and API helpers - and
so pydantic and YAML - into the startup path of every invocation.
Classes
gitea.cli.output.OutputFormat
Bases: StrEnum
Output formats accepted by the global --output option.
Functions:
gitea.cli.output.get_output_format
Get the output format requested for the current invocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Typer context carrying the state set by the root callback. |
required |
Returns:
| Type | Description |
|---|---|
OutputFormat
|
The requested output format, defaulting to |
Source code in src/gitea/cli/output.py
gitea.cli.output.print_envelope
Print a result as the {"data": ..., "metadata": ...} JSON envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Payload of the command. |
required |
metadata
|
dict[str, Any]
|
Information about the call that produced the payload. |
required |
Source code in src/gitea/cli/output.py
gitea.cli.output.emit
emit(
ctx: Context,
*,
data: Any,
metadata: dict[str, Any],
render_text: Callable[[], None] | None = None,
) -> None
Emit a command result in the format requested for this invocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Typer context carrying the state set by the root callback. |
required |
data
|
Any
|
Payload of the command, used for the JSON envelope. |
required |
metadata
|
dict[str, Any]
|
Information about the call, used for the JSON envelope. |
required |
render_text
|
Callable[[], None] | None
|
Callable printing the human-readable rendering. When omitted, the command prints nothing on stdout in text mode. |
None
|