ColorTerm Awareness in the Dolt CLI
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
The Dolt CLI inserts color metadata characters into output inconsistently. This makes it difficult to build around. As an example, there is currently a missing feature of `dolt log` which is the lack of the --patch flag. As a work around, I came up with this:
`dolt log -n 5 --oneline | sed -r "s/\x1B\[[0-9;]*[JKmsuG]//g" | awk '{print $1}' | xargs -I {} dolt show --skinny "{}" | less -R`
1) dolt log always outputs colors. The sed portion of that command above necesary. SInce log is writing to a pipe, it should drop colors.
2) dolt show has a colorized - kind of. It always colorized the commit id, but it doesn't colorize the +/- portions of the diff when a pipe is in use. Honestly, color would be nice in that context even though we are piping to less because less is color capable.
Git is smart about dropping all color information when it's writing to a pipe or something else which doesn't support XTERM colors. There are also the options you can put in your .gitconfig to force colors to never be output. Individual commands, such as `git diff`, have specific flags to enable colors, overriding the global default, those options are applied on a command by command basis.
There isn't a great way to fix this without auditing a lot of code, which is a lot of work.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.