-
Notifications
You must be signed in to change notification settings - Fork 302
Add colors to --help #1633
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
Add colors to --help #1633
Conversation
o2sh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better with colors, thanks @starsep 🎉
|
I think this could be done without adding one more dependency. Also, most likely it's incompatible with #1632 |
Yeah, looks like the value's type comes from clap-builder. https://docs.rs/clap-cargo/latest/clap_cargo/style/constant.CLAP_STYLING.html So we could probably define our own if we wanted. |
|
I don't know whether it's compatible with i18n PR. Yes, it's possible to do without dependency. use clap::builder::styling::{AnsiColor, Effects};
use clap::builder::Styles;
// ...
const STYLES: Styles = Styles::styled()
.header(AnsiColor::Green.on_default().effects(Effects::BOLD))
.usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
.literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
.placeholder(AnsiColor::Cyan.on_default());
// ...
#[command(styles = STYLES)]
pub struct CliOptions {I can prepare PR if you prefer this approach. |
|
Indeed, for something that simple, using a dependency isn't very useful. BTW, we could probably use the same styling as clap https://docs.rs/clap/latest/clap/builder/struct.Styles.html#example |
|
I used above style in #1634 |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [o2sh/onefetch](https://github.com/o2sh/onefetch) | minor | `2.25.0` → `2.26.1` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>o2sh/onefetch (o2sh/onefetch)</summary> ### [`v2.26.1`](https://github.com/o2sh/onefetch/blob/HEAD/CHANGELOG.md#2261-2025-12-21) [Compare Source](o2sh/onefetch@2.26.0...2.26.1) ##### Bug Fixes - Fix CD pipeline by [@​o2sh](https://github.com/o2sh) in [`becddb9`](o2sh/onefetch@becddb9) ### [`v2.26.0`](https://github.com/o2sh/onefetch/blob/HEAD/CHANGELOG.md#2260-2025-12-21) [Compare Source](o2sh/onefetch@2.25.0...2.26.0) ##### New Features - Add colors to --help by [@​starsep](https://github.com/starsep) in [#​1633](o2sh/onefetch#1633) ##### Chores - No unsafe by [@​Sk7Str1p3](https://github.com/Sk7Str1p3) in [#​1646](o2sh/onefetch#1646) - bump cargo edition to 2024 by [@​o2sh](https://github.com/o2sh) in [`a3062f4`](o2sh/onefetch@a3062f4) - increase default color resolution for sixel by [@​o2sh](https://github.com/o2sh) in [`73300b6`](o2sh/onefetch@73300b6) ##### Bug Fixes - skip get\_main\_language call if no language detected by [@​o2sh](https://github.com/o2sh) in [`10603ae`](o2sh/onefetch@10603ae) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi42NC4xIiwidXBkYXRlZEluVmVyIjoiNDIuNjQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
I used clap-cargo as it's easy to use and provides sensible default styles.
User can disable colors via
NO_COLOR=1environment variableOutput of
onefetch -h:NO_COLOR=1