Crates.io | kxxt-owo-colors |
lib.rs | kxxt-owo-colors |
version | 4.0.0 |
source | src |
created_at | 2023-10-24 04:59:08.555443 |
updated_at | 2024-02-14 07:35:47.85732 |
description | Zero-allocation terminal colors that'll make people go owo |
homepage | |
repository | https://github.com/kxxt/owo-colors |
max_upload_size | |
id | 1012061 |
size | 153,292 |
A zero-allocation no_std-compatible zero-cost way to add color to your Rust terminal to make people go owo.
Supports:
NO_COLOR
/FORCE_COLOR
environment variablesset_override
owo-colors is also more-or-less a drop-in replacement for colored, allowing colored to work in a no_std environment. No allocations or dependencies required because embedded systems deserve to be pretty too uwu.
To add to your Cargo.toml:
owo-colors = "3"
use owo_colors::OwoColorize;
fn main() {
// Foreground colors
println!("My number is {:#x}!", 10.green());
// Background colors
println!("My number is not {}!", 4.on_red());
}
use owo_colors::OwoColorize;
use owo_colors::colors::*;
fn main() {
// Generically color
println!("My number might be {}!", 4.fg::<Black>().bg::<Yellow>());
}
use owo_colors::OwoColorize;
println!("{}", "strikethrough".strikethrough());
use owo_colors::{OwoColorize, Stream::Stdout};
println!(
"{}",
"colored blue if a supported terminal"
.if_supports_color(Stdout, |text| text.bright_blue())
);
Supports NO_COLOR
/FORCE_COLOR
environment variables, checks if it's a tty,
checks if it's running in CI (and thus likely supports color), and checks which
terminal is being used. (Note: requires supports-colors
feature)