-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Terminal colors for output #636
base: master
Are you sure you want to change the base?
Conversation
If stderr isatty (i.e. the output is not being pumped to a file) and `$NO_COLOR` is unset or empty, or if `$FORCE_COLOR` is set and non-empty, output is colored. This helps distinguish `cabal2nix`'s output from the output of the fetchers it runs.
Good idea, I think this is a good migitation for the error message problem the current fetcher logic has! Not quite sure what to think about colored output, i.e. if the extra code is worth it… |
@sternenseemann Happy to remove the colored output if you'd prefer (or you can update my branch -- just drop the last commit), let me know |
I've merged those changes manually, we can leave this PR for the color changes. I'm going to keep thinking about it. Maybe @maralorn and @cdepillabout want to comment? |
I think I'm generally in favor of (optional) colors. For CLI programs that use color, I think I'd also expect a @9999years could you post a screenshot of what the colors look like in the output of cabal2nix? |
@cdepillabout Added a screenshot to the PR description! |
I think the colors seems nice, and it will likely make visually parsing the output of |
Unsurprisingly I am all in favor of colorful output. Code complexity seems manageable. |
This adds terminal colors to
cabal2nix
's output. This checks ifstderr
isatty
so that output will not be colored if (for example)cabal2nix
'sstderr
is being piped to a file. It also respects the$NO_COLOR
and$FORCE_COLOR
environment variables for toggling the output coloring (see no-color.org).A couple small changes while I was preparing this:
nix-prefetch-scripts
to theshell.nix
so that you can runcabal2nix
successfully while hacking on it.nix-prefetch-git ...
) before we run it. This makes it a lot clearer where the errors come from, and which errors are being ignored (because we're trying another fetcher).Example output: