Expand description
Consolidated styling module for terminal output.
This module uses the anstyle ecosystem:
- anstream for auto-detecting color support
- anstyle for composable styling
- Semantic style constants for domain-specific use
§stdout vs stderr principle
- stdout: Primary data output (table data, JSON, statusline)
- stderr: Status messages (progress, success, errors, hints, warnings)
This separation allows piping (wt list | grep foo) without status messages interfering.
Use println! for primary output, eprintln! for status messages.
Macros§
- eprint
- Prints to
stderr. - eprintln
- Prints to
stderr, with a newline. - Prints to
stdout. - println
- Prints to
stdout, with a newline.
Structs§
- Anstyle
Style - ANSI Text styling
- Formatted
Message - A message that has already been formatted with emoji and styling.
- Styled
Line - A line composed of multiple styled strings
- Styled
String - A piece of text with an optional style
Enums§
- Stream
- possible stream sources
Constants§
- ADDITION
- Addition style for diffs (green) - used in table rendering
- DEFAULT_
HELP_ WIDTH - Default width for help text rendering when terminal width is unknown. Used in both the CLI binary and tests for consistent output in docs.
- DELETION
- Deletion style for diffs (red) - used in table rendering
- ERROR_
SYMBOL - Error symbol (red ✗)
- GUTTER
- Gutter style for quoted content (commands, config, error details)
- GUTTER_
OVERHEAD - Width overhead added by format_with_gutter()
- HINT_
SYMBOL - Hint symbol (dim ↳)
- INFO_
SYMBOL - Info symbol (dim ○) - for neutral status
- PROGRESS_
SYMBOL - Progress symbol (cyan ◎)
- PROMPT_
SYMBOL - Prompt symbol (cyan ❯) - for questions requiring user input
- SUCCESS_
SYMBOL - Success symbol (green ✓)
- WARNING_
SYMBOL - Warning symbol (yellow ▲)
Functions§
- error_
message - Format an error message with symbol and red styling
- fix_
dim_ after_ color_ reset - Fix dim rendering for terminals that don’t handle \e[2m after \e[39m.
- format_
bash_ with_ gutter - Formats bash/shell commands with syntax highlighting and gutter
- format_
heading - Format a section heading (cyan uppercase text, no emoji)
- format_
toml - Formats TOML content with syntax highlighting using synoptic
- format_
with_ gutter - Formats text with a gutter (single-space with background color) on each line
- hint_
message - Format a hint message with symbol and dim styling
- hyperlink_
stdout - Format text as a clickable hyperlink for stdout, or return plain text if unsupported.
- info_
message - Format an info message with symbol (no color on text - neutral status)
- progress_
message - Format a progress message with symbol and cyan styling
- prompt_
message - Format a prompt message with symbol and cyan styling
- set_
verbosity - Set the global verbosity level.
- stderr
- Create an ANSI escape code compatible stderr
- stdout
- Create an ANSI escape code compatible stdout
- strip_
osc8_ hyperlinks - Strip OSC 8 hyperlinks while preserving other ANSI sequences (colors).
- success_
message - Format a success message with symbol and green styling
- suggest_
command - Build a suggested command string for hints.
- suggest_
command_ in_ dir - Like
suggest_command, but prepends-C <path>for commands targeting a specific worktree directory. - supports_
hyperlinks - Returns true if
streamis a TTY, and the current terminal supports_hyperlinks. - terminal_
width - Get terminal width, or
usize::MAXif detection fails. - truncate_
visible - Truncate a styled string to a visible width budget, preserving escapes. Escape sequences (ANSI/OSC) are zero-width; ellipsis (“…”) is added when truncating. Appends ESC[0m on truncation to avoid style bleed.
- verbosity
- Get the current verbosity level.
- visual_
width - Calculate visual width of a string, ignoring ANSI escape codes
- warning_
message - Format a warning message with symbol and yellow styling
- wrap_
styled_ text - Wrap ANSI-styled text at word boundaries, preserving styles across line breaks