https://github.com/zkat/supports-color
Detects whether a terminal supports color, and gives details about that support
https://github.com/zkat/supports-color
Last synced: about 1 year ago
JSON representation
Detects whether a terminal supports color, and gives details about that support
- Host: GitHub
- URL: https://github.com/zkat/supports-color
- Owner: zkat
- License: other
- Created: 2021-09-11T05:44:41.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T09:05:07.000Z (over 1 year ago)
- Last Synced: 2025-04-03T08:12:13.238Z (about 1 year ago)
- Language: Rust
- Size: 81.1 KB
- Stars: 44
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
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](https://github.com/sindresorhus)'
[NPM package by the same name](https://npm.im/supports-color).
## Example
```rust
use supports_color::Stream;
if let Some(support) = supports_color::on(Stream::Stdout) {
if support.has_16m {
println!("16 million (RGB) colors are supported");
} else if support.has_256 {
println!("256 colors are supported.");
} else if support.has_basic {
println!("Only basic ANSI colors are supported.");
}
} else {
println!("No color support.");
}
```