-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add color output support #1
Comments
Greetings from the Pull Request Club 👋🏽 I have an implementation using Also, I'm not sure the options should be specified via an import - I don't use Rex much so I'm not familiar with the ways it handles similar situations. Let me know what you think. |
Hey, @choroba, thanks for looking into this! About extra_command_optionWhile it certainly can produce colorized diffs in some cases, I'm afraid configurable diff options have a much wider impact than only coloring, which may lead us to a lot more details consider. Coloring feels a bit more like a beneficial side-effect of such feature. While we can consider supporting such feature overall, perhaps it's best to discuss that separately from coloring. We'll see what we find out :) About a coloring approach in generalI ended up with a local proof of concept experiment a while ago, which separates generating the diff from coloring it. It uses a highlighter command to post-process the diff output, for example I find the separation of concerns between the logic (how we obtain the diff) and the presentation (how we transform the diff) important. The diff output is coming from either the Alternatives I consideredAllowing configurable arbitrary diff command could work too, for example Another approach could be to parse the diff on our own by applying color tags to certain chunks or lines. I had an initial experiment with this a while back, and it felt a lot more fragile and complex to me than offloading it to a pre-existing specialized solution. Alternatives to checkPerhaps there's something on CPAN for coloring diffs already? 🤔 It may worth a look. About configuration optionsIn Rex contexts we have Nevertheless, I find an import argument like you proposed an interesting option to consider for configuration when we learn about a use case where Where we are now?Combining the above what I got curious about is the following approach:
|
Thanks for the detailed answer. I basically agree with everything, it would be great if you could push your hack somewhere for me to see. Just one idea: you mention "coloring/formatting command", but can't it be a Perl subroutine, too? I can imagine something simple like colouring red what starts with a |
Work-in-progress proof-of-concept hack
I updated some minor things in the maintain branch, and then pushed my proof-of-concept coloring code on top of that to the color_output branch. Big hack without tests or error checking, also breaks current tests, and needs delta for formatting – works though 😂 Since this is a WIP outside the default branch, it may change without further notice (though unlikely.) Coloring on our own
In my experience diff formatting/highlighting is a wide topic, and I strongly prefer to offload it to existing specialized tools. More importantly, each person tends to have their favorite format, and different formats may fit better for different situations – so making it configurable sounds wise. Providing an acceptable basic built-in coloring approach sounds nice 👍 Like how you propose matching some lines and colorize them with Term::ANSIColor + optionally Win32::Console::ANSI on Windows (which are already transitive dependencies through Rex itself, so we don't add new ones to the stack.) Previous similar attemptIn fact, using the General expectations
Additional thoughtsIdentified configuration opportunities to consider separatelyColoring and configurability sounds like two different (while related) feature, and it may be possible to discover and implement them separately. Your original idea was to allow configuring the command which gets the diff, and use a value that happens to return colored diffs. This is likely a good idea to support separately from coloring as soon as there's an actual real-world use case. If we succeed with a built-in basic coloring option, it may be good enough for a good while, and we can add configurable external highlighting separately later. Environment variables may be interesting to explore for configuration purposes as well (on top of Rex's built-in Possible performance cliffI wonder how useful it would be to set an upper limit on the size of diffs we attempt to colorize (or even show?). Unusually large ones may use too much resources or appear as stuck. It sounds like a separate concern, and I expect it's enough to solve when it becomes a problem. |
As a user, I would like have the hook's output colorized, in order to improve its readability.
The text was updated successfully, but these errors were encountered: