7 releases
0.2.2 | Mar 16, 2023 |
---|---|
0.2.1 | Mar 15, 2023 |
0.1.2 | Mar 13, 2023 |
0.0.1 | Mar 8, 2023 |
#367 in Command-line interface
866 downloads per month
Used in winnow
175KB
3.5K
SLoC
anstyle-stream
A simple cross platform library for writing colored text to a terminal.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Auto-adapting [stdout
] / [stderr
] streams
[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
# #[cfg(feature = "auto")] {
use anstyle_stream::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
Dependencies
~0–5MB
~84K SLoC