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

Add color help output #3

Open
joshka opened this issue Sep 12, 2024 · 1 comment
Open

Add color help output #3

joshka opened this issue Sep 12, 2024 · 1 comment

Comments

@joshka
Copy link
Contributor

joshka commented Sep 12, 2024

Color can make it easier to read the help text - e.g.:

image

In clap this is configured using clap::builder:Styles

const HELP_STYLES: Styles = Styles::styled()
    .header(AnsiColor::Blue.on_default().bold())
    .usage(AnsiColor::Blue.on_default().bold())
    .literal(AnsiColor::White.on_default())
    .placeholder(AnsiColor::Green.on_default());

#[skip_serializing_none]
#[derive(Debug, Serialize, Parser)]
#[command(author, version, about, styles = HELP_STYLES)]
pub struct Args {
    ...
}

It would be nice to support something similar. I'm happy to work on a PR for this if you're interested in this change.

@cbeck88
Copy link
Owner

cbeck88 commented Sep 18, 2024

Thanks for the suggestion.

Yeah, I'd like to support this.

So far, I didn't directly expose clap types in the API, but I don't really see a problem with having anstyle types in the API, that crate seems totally stable.

I think if we did a new-type wrapper around the Styles type from clap, we'd probably be able to expose the same API and still not be worried that uprev'ing clap (as our dependency) would break our public API?

And then otherwise we could have a styles argument that's similar to the example you show -- I'm thinking it would be a top-level only feature of a Conf struct?

I think that would be a nice patch -- I haven't thought through all the details but I can't see any problems with the idea. Let me know what you think

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

No branches or pull requests

2 participants