Git Product home page Git Product logo

supports-color's Introduction

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

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.");
}

supports-color's People

Contributors

afranchuk avatar aloso avatar dswij avatar hovinen avatar jam1garner avatar pacak avatar porges avatar sunshowers avatar zkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

supports-color's Issues

Issue a release + don't bump dev version numbers?

Hi! Was wondering if you'd be okay issuing a release of supports-color soon to include the fixes that have gone in since 2.0.0.

Separately, would it be okay not bumping the version to e.g. 2.0.1-alpha.0? Currently, [patch.crates-io] requires the version number to be identical which makes it hard to patch a version in from this repository. Leaving the version number at e.g. 2.0.0 would address this issue and allow workspaces to patch in the version.

Tests fail when run in unrecognised CI environment

Currently some of the tests will fail spuriously when their output is redirected to a file but the environment is not recognised as a CI environment. This unfortunately blocks my project's use of this crate.

The problem is that the code has a hard dependency on the is_terminal method and the tests cannot override that. To fix this, I would propose allowing that behaviour to be overridden with an additional environment variable. This seems reasonable since much of the rest of the crate's behaviour is also governed by environment variables.

I will prepare a PR for you to consider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.