bat icon indicating copy to clipboard operation
bat copied to clipboard

Improve error messages to avoid arrow ligature

Open injust opened this issue 6 months ago • 7 comments

This is the output I got when running bat cache without either required option (--build or --clear):

Image

The beginning of <--build|--clear> gets turned into a <-- ligature.

Maybe the error messages could be improved to avoid this?

injust avatar Jun 30 '25 10:06 injust

I'm interested in this one - I saw the good first issue label 😄

I’ve started looking through the code, and it seems like the usage line is generated by clap, not written directly by bat. I’ll dig a bit deeper if we can change the style by some options.

minty99 avatar Jul 15 '25 19:07 minty99

Ah sorry if it doesn't turn out to be so easy, I confess that I added the label without checking, I just assumed we had <--build hardcoded somewhere

keith-hall avatar Jul 15 '25 20:07 keith-hall

You're welcome! It still seems easy if the <--option_name> format is hard-coded in clap and customizable, then it should be an easy fix. If not, it might take a bit more work, but let’s see :)

minty99 avatar Jul 15 '25 20:07 minty99

I took a look inside clap, and it seems we can't easily change the < and > markers. We could use override_usage to work around this, but I don't think that's a great solution since we'd have to give up clap's smart usage generation. 😭

minty99 avatar Jul 16 '25 13:07 minty99

Thanks for looking @minty99, that indeed doesn't seem like an approach we would want to take. Maybe it's worth logging an issue on clap's repo @injust if there isn't one already.

keith-hall avatar Jul 16 '25 17:07 keith-hall

I'm not sure if this is a clap issue tbh. It's pretty conventional to represent required parts of a command with <...>.

I suspect I haven't seen this happen in other programs because mandatory options are a bit strange and I see subcommands used a lot more, e.g. uv cache prune.

injust avatar Jul 16 '25 23:07 injust

I also came across https://github.com/sharkdp/bat/issues/1726, which has relevant discussion about the bat cache command being problematic.

injust avatar Jul 16 '25 23:07 injust