Skip to content
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

--force-colorization does not work for --help #2778

Open
xeruf opened this issue Nov 18, 2023 · 2 comments
Open

--force-colorization does not work for --help #2778

xeruf opened this issue Nov 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@xeruf
Copy link
Contributor

xeruf commented Nov 18, 2023

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 (fc95468)

@xeruf xeruf added the bug Something isn't working label Nov 18, 2023
@eth-p
Copy link
Collaborator

eth-p commented Feb 8, 2024

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.

@sharkdp
Copy link
Owner

sharkdp commented Feb 8, 2024

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.

We actually do this already:

} else if wild::args_os().any(|arg| arg == "--no-config") {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants