bat
bat copied to clipboard
--force-colorization does not work for --help
What steps will reproduce the bug?
bat --help --force-colorization | cat
What happens?
No content formatting
What did you expect to happen instead?
flags are bold like when unpiped
How did you install bat?
Arch
bat version and environment
bat -V bat 0.24.0 (fc954685)
Great catch! I'm not really sure this is something that would be easy to fix, though.
bat uses clap for argument parsing and generating the --help message. By default, clap will only print the help message in color when printing to a terminal/tty. And in order to override clap's behaviour and force the help message to be colored, we would need to parse the --force-colorization argument using clap—which is a chicken and egg problem.
I suppose we could parse the arguments twice, but I don't feel like that's a good use of processing time for something that doesn't occur often and doesn't affect the user experience in a major way.
And in order to override clap's behaviour and force the help message to be colored, we would need to parse the
--force-colorizationargument using clap—which is a chicken and egg problem.
We actually do this already:
https://github.com/sharkdp/bat/blob/3761df9112e8cad0b2afca49dcea7d847f1a99f6/src/bin/bat/app.rs#L59
So it might not be too hard to fix. But I agree that it doesn't necessarily require fixing. --force-colorization is about bats standard output, not its --help text.