Bug 12273 – 'dmd -color' flag to colorize error/warning messages

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-27T12:26:00Z
Last change time
2017-05-13T18:22:56Z
Keywords
pull
Assigned to
nobody
Creator
timothee.cour2
See also
https://issues.dlang.org/show_bug.cgi?id=17396

Comments

Comment #0 by timothee.cour2 — 2014-02-27T12:26:50Z
clang and many other compilers have colorized error messages, it improves a lot readability such as pinpointing where the error is etc. I suggest having 'dmd -color' flag to colorize error/warning messages as well. As we've seen with the recent introduction of '-vcolumns' flag, simple things like this improve quite a bit the experience. This is trivial to implement on posix with terminal codes (I'm using it myself for my own logging), and should be doable on windows as well (SetConsoleTextAttribute?).
Comment #1 by dlang-bugzilla — 2014-02-27T12:28:50Z
Comment #2 by andrej.mitrovich — 2014-02-27T12:37:25Z
Seems like something that should or could be done in RDMD, especially since I've seen a few colorizing console libraries implemented in D.
Comment #3 by bugzilla — 2014-02-27T13:03:22Z
It's a good idea. Note to implementer: You'd have to check to see if the output stream is a file or a tty, and not do the colorizing for the file.
Comment #4 by timothee.cour2 — 2014-02-27T13:06:33Z
Using a postprocessor seems fragile/ambiguous. Come to think of it probably the most flexible solution would be to have a flag to output with markup (json for example), that can later be used by tools to print as html/terminal color codes/etc.
Comment #5 by bus_dbugzilla — 2014-02-28T14:32:45Z
Instead of a flag, wouldn't it be better to just do what the unixy tools do and automatically colorize if-and-only-if it detects it's outputting to an interactive shell? (Not sure whether that's doable on Windows though.)
Comment #6 by lio+bugzilla — 2014-06-30T06:51:57Z
Comment #7 by lio+bugzilla — 2014-06-30T06:54:29Z
Comment #8 by lio+bugzilla — 2014-06-30T06:56:33Z
As long as it's a flag, the TTY detection is not so important. If someone can figure out that part, we could make it the default and do away with the flag.
Comment #9 by github-bugzilla — 2014-07-02T11:08:35Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1bc0af1d9a8f963350ed8fb68ef9057f70cf89af Issue 12273 - Added -color[=on|off] flag Defaults to colored output if stderr is a TTY and TERM is not dumb.
Comment #10 by github-bugzilla — 2014-07-02T18:07:28Z
Comment #11 by lio+bugzilla — 2014-07-02T19:00:33Z