-
Notifications
You must be signed in to change notification settings - Fork 98
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
Beautify help messages #151
Conversation
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.
The help looks much nicer now, thanks.
Very pretty! Can you check if |
@blyxxyz It still works. By default |
Generated manpages seem to be okay. This is because coloring gets disabled when output is being redirected. However, It seems that |
@ducaale That's weird. Because clap also uses termcolor which respects |
OK, I found why. In clap 2.3, it implements color output through ansi_term instead of termcolor, which does not support I'm wondering if there is a way to inject |
This workaround is a bit ugly for me... Anyway, I will see your opinions tomorrow. |
src/cli.rs
Outdated
@@ -296,6 +303,11 @@ impl Cli { | |||
match Self::from_iter_safe(iter) { | |||
Ok(cli) => cli, | |||
Err(err) if err.kind == ErrorKind::HelpDisplayed => { | |||
let mut app = if env::var("NO_COLOR").is_ok() { |
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.
After experimenting a bit I think this is the best way out. It's possible to look at termcolor
's detection, but NO_COLOR
is really the only piece that's missing.
One nitpick, so unicode won't matter:
let mut app = if env::var("NO_COLOR").is_ok() { | |
let mut app = if env::var_os("NO_COLOR").is_some() { |
Ah, that's unfortunate. It already did that, so you can ignore it for this PR if you want, and I'll look at it later. The problem seems to be that Can you target |
One way this does affect But that doesn't affect the rendered man page so it's fine. |
wrap_help
feature to clapAppSettings::ColoredHelp
Before:
After: