Skip to main content

Crate bel7_cli

Crate bel7_cli 

Source
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 tables feature)
  • Clap argument helpers (requires clap feature)
  • Shell completion generation (requires completions feature)
  • Progress reporting (requires progress feature)

§Features

  • tables - Enables table styling with tabled
  • clap - Enables clap argument helper extensions
  • completions - Enables shell completion generation
  • progress - Enables progress reporting utilities
  • errors - Enables exit code mapping with sysexits
  • full - Enables all features

Structs§

Padding
Padding is responsible for a left/right/top/bottom inner indent of a particular cell.
StyledTable
A builder for styled tables.

Enums§

TableStyle
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.

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.