Giter VIP home page Giter VIP logo

supportscolor's Introduction

supports-color GoDoc

Features

This package provides a simple interface to query the level of color support found in a given terminal. This allows developers to know their users are seeing beautiful outputs, instead of junk like printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n".

  • Respects the --color flags, and additional colour specifications.
  • Handles TTY / Cygwin colour levels
  • Supports popular CI pipelines like TravisCI & CircleCI.

Roadmap

  • Check popular terminal support schemes (urvxt, xterm-256colour flag, etc.)
  • Proper unit tests (if possible)
  • Remove external dependency

Usage

import supportscolour

func main() {
    col := supportscolour.GetSupportLevel()
    if col.Has1m {
        // do something with truecolour
    } else if col.Has256 {
        // do something with 256 colours
    } else {
        // print out standard 16 colours.
    }
}

Install

go get -u github.com/johnaoss/supports-color

Contributing

Due to the nature of this problem, pull requests are appreciated if you find a terminal in which the data reported is inaccurate. I've currently only had access to a iTerm2 terminal, and as such I've only been able to test on the single platform.

License

This is licensed with the MIT License, and is found in the LICENSE file.

Thanks

Very much directly inspired by the npm module of the same name: github.com/chalk/supports-color !

supportscolor's People

Contributors

johnaoss avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.