pkl icon indicating copy to clipboard operation
pkl copied to clipboard

Add a --color flag to the CLI and disable colors for Pkl test

Open thomaspurchas opened this issue 1 year ago • 2 comments

The --colors flag makes it possible to forcefully disable colour output, and also forcefully enable it. We make use of this in the native Pkl test engines by passing --colors=never into the pkl commands, which ensures we get a predictable output.

Additionally the pkl test command also sets --colors=never to ensure that pkl test output isn't accidentially contaminated with ansi escape chars, which will break example based tests.

thomaspurchas avatar Jul 07 '24 21:07 thomaspurchas

This may be more complicated than what it's worth, but really, pkl test should color the "outside" exceptions and not the "inside" ones, i.e. if pkl test itself throws, it should be colored, but anything inside a module.catch(...) should not.

I don't think this is something that should hold you back, especially considering we want to try and avoid the Jansi dependency in pkl-core. @bioball's suggestion of passing in a formatter does seem the most sensible way to go.

holzensp avatar Jul 18 '24 13:07 holzensp

@holzensp yeah my plan to stop working on this approach, and look at passing in a formatter. As I mentioned here, the number of hacks and whatnot that are piling up to make this approach work doesn't feel good. I wouldn't be comfortable merging such a fragile pile of hacks and workarounds.

thomaspurchas avatar Jul 18 '24 14:07 thomaspurchas

Closing this; superseded by #746

bioball avatar Oct 31 '24 20:10 bioball