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

"help help" doesn't use color #538

Closed
joshtriplett opened this issue Jun 23, 2016 · 13 comments
Closed

"help help" doesn't use color #538

joshtriplett opened this issue Jun 23, 2016 · 13 comments
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies
Milestone

Comments

@joshtriplett
Copy link
Contributor

When clap provides a help subcommand, running command help help produces help for the help subcommand:

help 
Prints this message or the help of the given subcommand(s)

USAGE:
    help [FLAGS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

However, this help doesn't use color, unlike the help for every other subcommand.

@kbknapp
Copy link
Member

kbknapp commented Jun 24, 2016

That's a bug.

I used to protect against this, but I think I regressed a few versions back since I didn't add a test for it....thanks for letting me know!

@kbknapp kbknapp added C-bug Category: Updating dependencies P2: need to have A-help Area: documentation, including docs.rs, readme, examples, etc... labels Jun 24, 2016
@kbknapp kbknapp added this to the 2.7.0 milestone Jun 24, 2016
@kbknapp
Copy link
Member

kbknapp commented Jun 24, 2016

Aaaah, so digging into this, it actually wasn't a regression, but a logic bug I hadn't thought of.

When the feature to allow both versions help <subcmd> and <subcmd> help was added, it had the side affect of dispatching this strange behavior. Should be fixed quickly.

@kbknapp
Copy link
Member

kbknapp commented Jun 24, 2016

I have a local branch with this fixed. Once I knock out a few more issues I'll roll up the PR.

Also, I forgot to address the lack of color. This wasn't a bug per-se, the AppSettings::ColoredHelp isn't propagated through child subcommands unless one uses App::global_setting.

Either way, the fix I have correctly dispatches <cmd> help help to the <cmd> help message (same as <cmd> help. And it's colored without global_setting.

@joshtriplett
Copy link
Contributor Author

joshtriplett commented Jun 24, 2016

Also, I forgot to address the lack of color. This wasn't a bug per-se, the AppSettings::ColoredHelp isn't propagated through child subcommands unless one uses App::global_setting.

I had used global_setting, though, and help help still didn't use color.

Either way, the fix I have correctly dispatches help help to the help message (same as help.

That seems unusual; I think it made sense for cmd help help to show the help for the help subcommand, for consistency with cmd help anothersubcmd.

@kbknapp
Copy link
Member

kbknapp commented Jun 24, 2016

That seems unusual; I think it made sense for cmd help help to show the help for the help subcommand, for consistency with cmd help anothersubcmd.

I hadn't thought of it like that. Hmmm....let me see if I can make that work before pushing this PR since the more I think about it, the more I like how you stated it.

@kbknapp
Copy link
Member

kbknapp commented Jun 24, 2016

Ok, I got this working in the way you said, and I'm much happier with it now. Should be able to roll up the PR in a minute.

@homu homu closed this as completed in e3d2893 Jun 24, 2016
@laishulu
Copy link

laishulu commented Jul 22, 2016

I have a subcommand foo, I run myapp help foo, I still can't see any color, even I have the following codes.

    let yaml = load_yaml!("cli.yml");
    let app_m = clap::App::from_yaml(yaml)
        .setting(clap::AppSettings::SubcommandRequired)
        .global_setting(clap::AppSettings::ColoredHelp)
        .get_matches();

the clap version is 2.9.2

@laishulu
Copy link

Any feedback?

@kbknapp
Copy link
Member

kbknapp commented Jul 23, 2016

@chenhouwu this is because the global settings need to be applied prior to the subcommand being added to the parent command. Adding a global_setting: "ColoredHelp" to your top level command in the yaml should fix this.

@laishulu
Copy link

laishulu commented Jul 23, 2016

Still the same result following your instruction, i.e. help for main command is colored, but help for subcommand is not colored.

also, I can run if I have the following line in the yml file, what's the correct way to config this?

setting: "SubcommandRequired"

@kbknapp
Copy link
Member

kbknapp commented Jul 23, 2016

Could you open a new issue for this, it'll be easier to track and fix that way. 😉

@laishulu
Copy link

for the uncolored subcommand, see this issue: #591

@laishulu
Copy link

OK now, with the following lines in the yml file

global_settings:
    - ColoredHelp

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-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

3 participants