Skip to content

harbor_cli.format

Output format of command results.

Not a part of the output module to avoid circular imports caused by the instantiation of the global state object, which imports other modules that rely on output formats.

Attributes

OUTPUTFORMAT_REPR = {OutputFormat.TABLE: 'table', OutputFormat.JSON: 'JSON'} module-attribute

OUTPUTFORMAT_EMOJI = {OutputFormat.TABLE: ':page_facing_up:', OutputFormat.JSON: ':package:'} module-attribute

Classes

OutputFormat

Bases: Enum

Output format of the command result.

Source code in harbor_cli/format.py
class OutputFormat(Enum):
    """Output format of the command result."""

    TABLE = "table"
    JSON = "json"

Attributes

TABLE = 'table' class-attribute instance-attribute
JSON = 'json' class-attribute instance-attribute

Functions

output_format_repr(fmt: OutputFormat) -> str

Return a human-readable representation of an output format.

Source code in harbor_cli/format.py
def output_format_repr(fmt: OutputFormat) -> str:
    """Return a human-readable representation of an output format."""
    f = OUTPUTFORMAT_REPR.get(fmt)
    if f is None:
        warning(f"Unknown output format: {fmt}")
        f = "Unknown"
    return f

output_format_emoji(fmt: OutputFormat) -> str

Return an emoji for an output format.

Source code in harbor_cli/format.py
def output_format_emoji(fmt: OutputFormat) -> str:
    """Return an emoji for an output format."""
    f = OUTPUTFORMAT_EMOJI.get(fmt)
    if f is None:
        warning(f"Unknown output format: {fmt}")
        f = ":question:"
    return f