Expand description
Terminal UI utilities for click-rs.
This module provides terminal input/output functions for building interactive command-line applications. It includes styled output, user prompts, progress bars, and terminal utilities.
§Features
- Output Functions:
echo,secho, andstylefor formatted terminal output - Input Functions:
prompt,confirm,getchar, andpausefor user input - Progress Bars: Visual progress indication with ETA and percentage
- Terminal Utilities: Screen clearing, size detection, TTY checks
§Example
use click::termui::{echo, secho, style, prompt, confirm, Color};
// Simple output
echo("Hello, world!", true, false, None);
// Styled output
secho("Success!", Some(Color::Green), None, true, false, false, false, false, false, false, true, true, false, None);
// Create a styled string
let styled = style("Error", Some(Color::Red), None, true, false, false, false, false, false, false, false);
// Prompt for input
let name = prompt("Enter your name", Some("World".to_string()), false, false, |s| Ok(s.to_string())).unwrap();
// Confirmation
if confirm("Continue?", Some(true), false).unwrap() {
// proceed
}Structs§
- Progress
Bar - A progress bar for displaying operation progress.
- Progress
BarIter - An iterator wrapper that displays a progress bar.
Enums§
- Color
- Terminal colors for styled output.
Constants§
- BLACK
- BLUE
- BRIGHT_
BLACK - BRIGHT_
BLUE - BRIGHT_
CYAN - BRIGHT_
GREEN - BRIGHT_
MAGENTA - BRIGHT_
RED - BRIGHT_
WHITE - BRIGHT_
YELLOW - CYAN
- GREEN
- MAGENTA
- RED
- RESET
- WHITE
- YELLOW
Functions§
- clear
- Clear the terminal screen.
- confirm
- Prompt for yes/no confirmation.
- echo
- Print a message to the terminal.
- echo_
via_ pager - Display text via a pager.
- edit_
text - Open a text editor for the user to edit content.
- get_
terminal_ size - Get the terminal size as (width, height).
- getchar
- Read a single character from the terminal.
- isatty
- Check if a file descriptor refers to a TTY.
- launch
- Open a URL or file path in the default application.
- pause
- Pause until the user presses any key.
- progressbar
- Wrap an iterator with a progress bar display.
- prompt
- Prompt the user for input with optional type conversion.
- secho
- Print a styled message to the terminal.
- stderr_
isatty - Check if stderr is connected to a TTY.
- stdin_
isatty - Check if stdin is connected to a TTY.
- stdout_
isatty - Check if stdout is connected to a TTY.
- strip_
ansi_ codes - Strip ANSI escape codes from a string.
- style
- Style text with ANSI escape codes.