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

Allow templates to change the error message strings #2196

Closed
2 tasks done
filipelbc opened this issue Oct 31, 2020 · 3 comments
Closed
2 tasks done

Allow templates to change the error message strings #2196

filipelbc opened this issue Oct 31, 2020 · 3 comments
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-duplicate Status: Closed as Duplicate
Milestone

Comments

@filipelbc
Copy link

Before anything, this library is great! Thanks!

Make sure you completed the following tasks

Describe your use case

I prefer printing ERROR: ... instead of error: ..., and to make the background red, instead of the foreground.

Describe the solution you'd like

Allow the user to set the "error: " string, which is currently hard-coded, see

c.error("error:");

Allow the user to change the colors, currently hard-coded, see

self.pieces.push((msg.into(), Some(Color::Red)));

You could create a StyleSetting struct and a mechanism similar to AppSettings.

struct StyleSetting {
    string: &str,
    style: termcolor::ColorSpec,
}

enum StylePoint {
    ErrorStart,
    UsageStart,
    ...
}

let my_error_style = StyleSetting::new("ERROR: ", my_error_color_spec);

App::new("Foo")
    ...
    .style_setting(ErrorStart, my_error_style)
    ...

Additional context

Similar to #2035, but instead of allowing usage of Clap's error formatting, allow the user to customize Clap's messages and style to fit his preferences.

@filipelbc filipelbc changed the title Allow customization of error message style (and possible others) Allow customization of error message style (and possibly others) Oct 31, 2020
@pksunkara
Copy link
Member

Note: Same as #1433 but this issue needs error message template support.

@pksunkara pksunkara added this to the 3.1 milestone Oct 31, 2020
@pksunkara pksunkara changed the title Allow customization of error message style (and possibly others) Allow templates to change the error message strings Oct 31, 2020
@pksunkara
Copy link
Member

Might also be related to #1734

@epage epage added A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations and removed C: colorizing labels Dec 8, 2021
@epage
Copy link
Member

epage commented Dec 13, 2021

This request seems most like #1790 which we closed because we are not looking at allowing granular styling of claps API, instead favoring templates and #1433. Since we have #1734 for an error message template and #1433 for styling it, I'm going to go ahead and close this out.

If there is any concern with this plan, let us know!

@epage epage closed this as completed Dec 13, 2021
@epage epage added the S-duplicate Status: Closed as Duplicate label Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-duplicate Status: Closed as Duplicate
Projects
None yet
Development

No branches or pull requests

3 participants