Module display

Module display 

Source
Expand description

Display utilities for mi6-cli output formatting.

This module consolidates display logic into reusable components:

  • terminal: Terminal width detection and color support
  • string: String truncation helpers (UTF-8 safe)
  • colors: Color formatting helpers (bold, colored text)
  • format: Number, duration, and byte formatting
  • table: Table header and column width calculations
  • event: Event row formatting and details
  • prompt: User confirmation prompts

Structs§

StderrColors
ANSI color codes for terminal output to stderr.

Constants§

COL_APP
COL_DETAILS_MIN
COL_EVENT
COL_PID
COL_SESSION
COL_SOURCE
COL_TIME
DEFAULT_TERMINAL_WIDTH
Default terminal width if detection fails.

Functions§

bold_green
Format text as bold green.
bold_red
Format text as bold red.
bold_white
Format text as bold white.
calculate_details_width
Calculate the details column width based on terminal width and whether APP column is shown.
confirm
Ask the user for confirmation, prompting on stderr.
confirm_stdout
Ask the user for confirmation, prompting on stdout.
dark_grey
Format text as dark grey (for hints).
format_bytes
Format bytes as a human-readable string.
format_details
Format details for an event.
format_duration
Format a duration in milliseconds as a human-readable string.
format_number
Format a large number with comma separators.
framework_abbrev
Get 3-letter abbreviation for a framework.
get_display_event_type
Get the display event type name for an event. For API requests, check metadata for Codex activity event types.
get_terminal_width
Get terminal width using stty, falling back to default.
percentage
Calculate percentage with zero-division handling.
print_event_row
Print a single event as a table row.
print_table_header
Print the table header.
truncate_from_start
Truncate a string from the start if it exceeds max_len. Returns the first max_len characters (no ellipsis added).
truncate_str
Truncate a string to a maximum number of characters, returning a reference to the truncated slice.
truncate_with_prefix
Truncate a string with ellipsis prefix if it exceeds max_len. Returns the last (max_len - 3) characters prefixed with “…”.
use_colors
Check if we should use colors.
use_colors_stderr
Check if we should use colors for stderr output.