Expand description
Auto-adapting stdout / stderr streams
A portmanteau of “ansi stream”
AutoStream always accepts ANSI escape codes,
adapting to the user’s terminal’s capabilities.
Benefits
- Allows the caller to not be concerned with the terminal’s capabilities
- Semver safe way of passing styled text between crates as ANSI escape codes offer more compatibility than most crate APIs.
Example
use anstream::println;
use owo_colors::OwoColorize as _;
// Foreground colors
println!("My number is {:#x}!", 10.green());
// Background colors
println!("My number is not {}!", 4.on_red());And this will correctly handle piping to a file, etc
Modules
- Gracefully degrade styled output
Macros
- eprint
autoPrints tostderr. - eprintln
autoPrints tostderr, with a newline. - panic
autoPanics the current thread. - print
autoPrints tostdout. - println
autoPrints tostdout, with a newline.
Structs
std::io::Writethat adapts ANSI escape codes to the underlyingWrites capabilities- In-memory
RawStream - Only pass printable data to the inner
Write
Enums
- ColorChoice
autoSelection for overriding color output withforce_colorSelection for overriding color output withset
Traits
- Explicitly lock a
std::io::Writeable - RawStream
autoand not (Windows andwincon)Required functionality for underlyingstd::io::Writefor adaptation
Functions
- force_color
autoOverride the detectedColorChoice - stderr
autoCreate an ANSI escape code compatible stderr - stdout
autoCreate an ANSI escape code compatible stdout