Skip to content

tux.cli.ui

Terminal UI utilities for the CLI.

This module provides rich formatting for terminal output.

Functions:

Name Description
command_header

Print a header for a command.

command_result

Print the result of a command.

create_table

Create a rich table with the given title and columns.

Functions

command_header(group_name: str, command_name: str) -> None

Print a header for a command.

Source code in tux/cli/ui.py
Python
def command_header(group_name: str, command_name: str) -> None:
    """Print a header for a command."""
    text = Text()

    text.append("Running ", style="dim")
    text.append(f"{group_name}", style=INFO_STYLE)
    text.append(":")
    text.append(f"{command_name}", style=SUCCESS_STYLE)

    console.print(text)

command_result(is_success: bool, message: str = '') -> None

Print the result of a command.

Source code in tux/cli/ui.py
Python
def command_result(is_success: bool, message: str = "") -> None:
    """Print the result of a command."""

    if is_success:
        if message:
            success(message)

        else:
            success("Command completed successfully")

    elif message:
        error(message)

    else:
        error("Command failed")

create_table(title: str, columns: list[str]) -> Table

Create a rich table with the given title and columns.

Source code in tux/cli/ui.py
Python
def create_table(title: str, columns: list[str]) -> Table:
    """Create a rich table with the given title and columns."""

    table = Table(title=title)

    for column in columns:
        table.add_column(column)

    return table