Hello everyone!
In one of my projects I am compiling a nim file from within another nim script, and retrieving errors by using the execCmdEx function to get the stderr that the compilation produces. I know I could use execCmd instead, but I need the string from stderr to do some further parsing of the result.
I'd like to print this stderr with the same color highlighting as if executing the compilation from the command line (e.g. Error: are highlighted in red, Warning: in orange). I tried to look into nim's source code to see where this pretty printing happens, but couldn't find it. Is there an easy solution? (I know of terminal, but I'd have to parse the string for specific things, etc...).
Thanks!
I'm aware of that option, and it works for coloring the output of the nim compiler.
However, I'm getting the output of the compiler via stdout, and store it in a string. I'd like to print this output just as if I would run it on the command line with colors:on
@vitreo12 For compiler coloring - https://github.com/nim-lang/Nim/blob/610e9b2fe9d5908b9941939e975f394aba009b43/compiler/msgs.nim#L485 , and just compiler/msgs in general.
But if you need to get compilation output as string and then pretty-print it with colors I would recommend to just do replace("Warning", "\e[31mWarning\e[0m") or something similar (ansi escape codes)