Expand description
Common CLI utilities for Rust command-line applications.
This crate provides:
- Colored console output helpers (success, error, warning, info)
- String truncation for display
- Table styling utilities (requires
tablesfeature) - Clap argument helpers (requires
clapfeature) - Shell completion generation (requires
completionsfeature) - Progress reporting (requires
progressfeature)
§Features
tables- Enables table styling withtabledclap- Enables clap argument helper extensionscompletions- Enables shell completion generationprogress- Enables progress reporting utilitieserrors- Enables exit code mapping withsysexitsfull- Enables all features
Structs§
- Padding
- Padding is responsible for a left/right/top/bottom inner indent of a particular cell.
- Styled
Table - A builder for styled tables.
Enums§
- Table
Style - Available table styles for CLI output.
Constants§
- DEFAULT_
TERMINAL_ WIDTH - Default terminal width when detection fails.
- DEFAULT_
TRUNCATION_ SUFFIX - Default suffix appended to truncated strings.
- SHELL_
DETECTION_ ENV_ VARS - Environment variables used for shell detection.
Traits§
- Command
Shell Ext - Extension trait for
std::process::Commandto help with shell detection tests.
Functions§
- build_
table_ with_ columns - Builds a table with only the specified columns.
- display_
option - Formats an optional value for rendering in a table cell.
- display_
option_ or - Formats an optional value with a default.
- format_
bold - Formats a value as bold if colors are enabled.
- format_
dimmed - Formats a value as dimmed/muted if colors are enabled.
- format_
error - Formats a value as error (red) if colors are enabled.
- format_
info - Formats a value as info (blue) if colors are enabled.
- format_
success - Formats a value as success (green) if colors are enabled.
- format_
warning - Formats a value as warning (yellow) if colors are enabled.
- parse_
columns - Parses a comma-separated column list into a vector of lowercase column names.
- print_
dimmed - Prints a dimmed/muted message.
- print_
error - Prints an error message to stderr with a red X prefix.
- print_
info - Prints an info message with a blue arrow prefix.
- print_
success - Prints a success message with a green checkmark prefix.
- print_
warning - Prints a warning message with a yellow exclamation prefix.
- responsive_
width - Returns a target width for tables based on terminal size.
- should_
colorize - Returns whether colored output should be used.
- should_
colorize_ stderr - Returns whether colored output should be used for stderr.
- terminal_
width - Returns the current terminal width in columns.
- truncate_
middle - Truncates a string in the middle, keeping start and end.
- truncate_
string - Truncates a string to a maximum number of characters.
- truncate_
with_ suffix - Truncates a string with a custom suffix.