Detects whether a terminal supports color, and gives details about that support
- Rust 100%
| .github | fix(clicolor): Ignore unit tests on GH action and change order of CLICOLOR check ( #5 ) | |
| src |
fix(unsafe): Remove unsafe code in favor of OnceLock ( #20 )
|
|
| tests | tests: Add miri testing of cache unsafe code to CI ( #2 ) | |
| .editorconfig | meta: add .editorconfig | |
| .gitignore | feat(api): initial commit | |
| Cargo.toml | chore: Release supports-color version 3.0.2 | |
| CHANGELOG.md | docs: update changelog | |
| cliff.toml | meta: fix cliff.toml | |
| LICENSE | feat(api): initial commit | |
| Makefile.toml | feat(api): initial commit | |
| README.md | fix(docs): Update README example for accuracy ( #7 ) | |
Detects whether a terminal supports color, and gives details about that
support. It takes into account the NO_COLOR environment variable.
This crate is a Rust port of @sindresorhus' NPM package by the same name.
Example
usesupports_color::Stream;ifletSome(support)=supports_color::on(Stream::Stdout){ifsupport.has_16m{println!("16 million (RGB) colors are supported");}elseifsupport.has_256{println!("256 colors are supported.");}elseifsupport.has_basic{println!("Only basic ANSI colors are supported.");}}else{println!("No color support.");}