AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 349 forks source link

Output plain template when NO_COLOR environment variable is set #475

Closed zimeg closed 1 year ago

zimeg commented 1 year ago

Summary

This PR checks for a non-empty NO_COLOR environment variable and displays templates without color if one is present, as specified by the references in #447.

Fixes #447

Preview

https://user-images.githubusercontent.com/18134219/205460922-8b6a854b-e4e6-4daf-93b8-3e8ed63ca6be.mov

Reviewers

The following steps can be used to inspect these changes:

  1. Checkout this branch
  2. In a project using survey, append the following to your go.mod, pointing to your local survey source:
replace github.com/AlecAivazis/survey/v2 v2.3.6 => ../../go-survey/survey
  1. Run your project with color support by ensuring NO_COLOR is not set:
$ unset NO_COLOR
$ ./your-survey-project
  1. Run your project with colors removed from survey outputs:
$ export NO_COLOR=true
$ ./your-survey-project

Notes

AlecAivazis commented 1 year ago

Seems totally fine to me 👍