Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@starsep
Copy link
Contributor

@starsep starsep commented Nov 23, 2025

I used clap-cargo as it's easy to use and provides sensible default styles.
User can disable colors via NO_COLOR=1 environment variable

Output of oxipng --help:

before after NO_COLOR=1
oxipng-before oxipng-colors oxipng-no-color

@TPS
Copy link

TPS commented Nov 23, 2025

I used clap-cargo as it's easy to use and provides sensible default styles.

@starsep Per #574, OxiPNG already has color/NOCOLOR support via anstream, so maybe doesn't need clap-cargo also? Or maybe replace it, if sensible? Keeping dependencies minimal & optional is a bit of secondary goal around here, evidentally.

@starsep
Copy link
Contributor Author

starsep commented Nov 23, 2025

Actually clap-cargo wasn't used for NO_COLOR support. It only provided style. I removed it

NO_COLOR seems handled by clap, unfortunately NOCOLOR doesn't seem to work.
There is color argument for clap builder which perhaps could be set based on environment variable

@andrews05
Copy link
Collaborator

Hi @starsep, thanks for your PR.
As I recall, we used to have coloured output for the help under a previous version of clap (v2 or 3), and then clap v4 changed the default output to not be coloured anymore. There's currently an open discussion on the matter where they're reconsidering the default colours and styles.
Your styles here do look pretty sensible, though I wonder if it would be good to wait for clap's guidance here?

@starsep
Copy link
Contributor Author

starsep commented Nov 24, 2025

I was aware of clap changes but not of this discussion, thanks!
From my perspective lack of colors in v4 was a UX regression hence my PR πŸ˜„

Default clap provided style would be nice but I don't consider it a blocker.
Migrating to it once it's released should be easy

@andrews05
Copy link
Collaborator

@starsep Is your screenshot still accurate after your latest change? I notice the styles you've set aren't identical to clap_cargo. Did you prefer the non-bright colours?

Btw, if you feel strongly about colours it might be good if you add your feedback to the clap discussion, seeing as they're looking for input.

@starsep
Copy link
Contributor Author

starsep commented Nov 26, 2025

I will add the feedback, I just need to gather my thoughts πŸ˜„.

I have strong feelings about having colors, not so strong about particular values as long as everything is readable.

I wasn't 100% sure whether I updated the image but looks the same.
New one generated using freeze -x "./target/debug/oxipng --help" --theme monokai --font.size 4 --padding 1 and oxipnged:

517833915-a4ee13d1-5920-4253-acf6-23481ac1c80f

@andrews05
Copy link
Collaborator

Yeah, I don't have strong feelings either. I'm just wondering if the "bright" colours used in clap-cargo might be better for readability.

@TPS
Copy link

TPS commented Nov 27, 2025

A stronger contrast is helpful in low-light or -vision (a11y) scenarios, if 1 is already overriding user's TUI setup a bit via color.

@AlexTMjugador
Copy link
Member

Most terminal themes adjust the ANSI colors requested by programs as needed so that they are somewhat readable anyway when considering the likely surrounding colors. For example, here is the colored output of cargo --help when viewed under both an usual dark theme, and a more unusual light, solarized theme:

image image

Therefore, as Monokai is a reasonably well-calibrated theme, I think chances are that it'll look also fine in most other well-done themes, and the responsibility of ensuring proper contrast is moved to either theme authors or end-users selecting the theme they feel the most comfortable with.

In my view, now that accessibility concerns are set aside, choosing the most beautiful color palette for Oxipng is bound to be an endless debate where everyone will very reasonably have their own preference, so I don't think we should aim to resolve that in this PR. Instead, I think that we could be more pragmatic and consider that some color is arguably better than no color, because the usage of different colors has been shown to help shape interactions of people with different parts of an UI, and we want that here to make it easier for people to read the documentation. (After all, most people can't really imagine a code editor that doesn't do any syntax highlighting with different colors, right?)

So, let's merge this! πŸš€

@AlexTMjugador AlexTMjugador mentioned this pull request Dec 6, 2025
Merged
@AlexTMjugador AlexTMjugador merged commit 6a2379c into oxipng:master Dec 6, 2025
11 checks passed
@starsep starsep deleted the colorful-help branch December 6, 2025 15:43
@ace-dent
Copy link

ace-dent commented Dec 6, 2025

@AlexTMjugador @andrews05 @starsep
Testing the CI artefact under macOS.

Screenshots attached (system dark and light themes).
My 2Β’ – The colorised version is slightly harder to read with the light theme... but then I'm not sure what a better alternative could be!?... πŸ€·πŸΌβ€β™‚οΈ

Screenshot 2025-12-06 at 19 35 42 Screenshot 2025-12-06 at 19 35 09

Workaround for macOS users: env NO_COLOR=1 oxipng -h... but then we lose the bold formatting for parameters :-(

@andrews05
Copy link
Collaborator

andrews05 commented Dec 6, 2025

@AlexTMjugador you're posting screenshots from cargo, but as noted earlier the colours set here aren't identical. Are you sure we don't want to match? If cargo's colours are commonly used, it might be good for consistency.

@ace-dent I'm afraid I don't have much helpful to say on the matter, other than colours are hard. It's true that the colours don't stand out as much on the light theme there but I think it's probably acceptable. People who really struggle with colours will likely have already tailored their theme to work for them.

@AlexTMjugador
Copy link
Member

AlexTMjugador commented Dec 6, 2025

@AlexTMjugador you're posting screenshots from cargo, but as noted earlier the colours set here aren't identical. Are you sure we don't want to match? If cargo's colours are commonly used, it might be good for consistency.

Besides Cargo, I've also tested a random selection of CLI apps I had readily available (Docker, Hyperfine, yt-dlp, vim, psql, oggenc, btop, k9s, nix) in my KDE Breeze terminal theme and the result were basically far from consistent:

  • Most apps just didn't bother coloring their --help output on an interactive terminal at all.
  • btop and Hyperfine displayed the same blue accent colors.
  • Cargo was the only CLI that displayed green-ish colors as shown above.
  • nix --help bothered with an admittedly pretty (and unique) mix of red, blue and yellow accents. (And it also piped the output through the less pager, making it easier to navigate! Maybe some future Oxipng PR or issue requests this at some point...)

So I don't think there is anything close to a widely-observed standard in what colors CLI apps should use for "manual-like" output, and thus Oxipng picking a somewhat random choice here is basically equivalent to what other apps do.

It's true that the colours don't stand out as much on the light theme there but I think it's probably acceptable. People who really struggle with colours will likely have already tailored their theme to work for them.

Yeah, the light terminal themes usually come across as worse in contrast, in my opinion. Some people prefer that, though. I'd say that particular themes looking worse is not anything we should try to fix on the Oxipng side of things, because the precise colors used are highly dependent on the precise terminal configuration, and thus asking the terminal to print reasonably different colors is the best we can do (and are already doing): they may end up being completely different anyway.

@andrews05
Copy link
Collaborator

Well I think someone ought to come up with a standard for everyone to use πŸ˜„

@TPS
Copy link

TPS commented Dec 6, 2025

Well I think someone ought to come up with a standard for everyone to use πŸ˜„

@andrews05 You have successfully incanted… the obligatory xkcd!
Standards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants