jwt-cli
jwt-cli copied to clipboard
Add syntax highlighting
Colors! Because who doesn't like them?!
Just opening this PR to see if there's demand. It's a really slow/lazy way to implement syntax highlighting but it works. I can improve the implementation if there's a need.
Summary
JSON syntax highlighting:
The color turns off if the application is not outputting to a TTY:
Preflight checklist
- [X] Code formatted with rustfmt
- [ ] Relevant tests added
- [ ] Any new documentation added
Hey @ambiso, thanks for this, and thanks for your patience! I think this looks ok to me, although I wonder if there should be a flag to turn this off. I think it's probably ok to not have one for now unless folks start raising issues about it, but I'd like to get your thoughts.
Finally, looks like there's some cargo conflicts. If you have time, could you merge/rebase?
I rewrote the changes for the latest version; I tried adding a --color=always | never | auto
flag, but couldn't find a neat way to do it with clap - it has support for a ColorChoice
but it doesn't look like it's easy to support this ColorChoice
as a command line flag. https://docs.rs/clap/latest/clap/builder/struct.Command.html#method.color
Thanks @ambiso! In researching a solution for #197, I realized that bunt via termcolor has support for this that we could emulate (or maybe bat supports NO_COLOR
?)