Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add flag for turning off colors in TTY printing #214

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

varungandhi-src
Copy link
Contributor

It is a bit annoying to copy the colored output into something like Markdown.

Test plan

Manually checked.

With scip print or scip print --color=true:

image

With scip print --color=false

image

@varungandhi-src varungandhi-src force-pushed the vg/turn-off-colors branch 3 times, most recently from 2993496 to 960f7d2 Compare October 31, 2023 11:09
@keynmol
Copy link
Contributor

keynmol commented Oct 31, 2023

Given you're already touching this code, would be good to follow the CLI conventions (https://clig.dev/#output) and at least handle NO_COLOR env variable as well:

Use color with intention. For example, you might want to highlight some text so the user notices it, or use red to indicate an error. Don’t overuse it—if everything is a different color, then the color means nothing and only makes it harder to read.

Disable color if your program is not in a terminal or the user requested it. These things should disable colors:

    stdout or stderr is not an interactive terminal (a TTY). It’s best to individually check—if you’re piping stdout to another program, it’s still useful to get colors on stderr.
    The NO_COLOR environment variable is set.
    The TERM environment variable has the value dumb.
    The user passes the option --no-color.
    You may also want to add a MYAPP_NO_COLOR environment variable in case users want to disable color specifically for your program.

@varungandhi-src
Copy link
Contributor Author

Added handling for NO_COLOR.

cmd/scip/print.go Outdated Show resolved Hide resolved
@varungandhi-src varungandhi-src merged commit 4e535ae into main Nov 1, 2023
3 checks passed
@varungandhi-src varungandhi-src deleted the vg/turn-off-colors branch November 1, 2023 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants