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

Apply color settings recursively? #223

Closed
dpc opened this issue Aug 4, 2019 · 9 comments
Closed

Apply color settings recursively? #223

dpc opened this issue Aug 4, 2019 · 9 comments
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@dpc
Copy link

dpc commented Aug 4, 2019

    #[structopt(raw(setting = "structopt::clap::AppSettings::ColorAuto"))]
    #[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))]

It seems I have to copy&paste it before every single sub-command to get colored help everywhere as per "NOTE: When these settings are used, they apply only to current command, and are not propagated down or up through child or parent subcommands" https://docs.rs/structopt/0.2.18/structopt/clap/enum.ArgSettings.html

Is there any shortcut?

@TeXitoi
Copy link
Owner

TeXitoi commented Aug 6, 2019

Sorry no, a bit related to #172

@TeXitoi TeXitoi added the enhancement We would love to have this feature! Feel free to supply a PR label Aug 6, 2019
@CreepySkeleton
Copy link
Collaborator

@dpc Well, in structopt 0.3 you'll be able to do something like this

use structopt::clap::AppSettings::*;

#[structopt(setting(ColorAuto), setting(ColoredHelp))]

which is a way shorter than it used to be. You're still going to have to copy-paste in on every subcommand, I don't think we can do much about it in structopt.

@dpc
Copy link
Author

dpc commented Aug 23, 2019

That's the thing - copy-pasting it over 100 subcommands I have is not awesome. I don't even understand why would anyone want colors in some subcommands but not the others. :D

@TeXitoi
Copy link
Owner

TeXitoi commented Aug 23, 2019

That's inherited from clap: you have to do that with clap. This issue is open to discuse a solution and someone can then simplement it. PR welcome.

@CreepySkeleton
Copy link
Collaborator

CreepySkeleton commented Aug 24, 2019

@dpc will clap::App::global_setting(ColoredHelp) do the trick? If so, you can use it with structopt 0.3 via

#[structopt(global_setting(ColoredHelp))]

or

#[structopt(raw(global_setting = "structopt::clap::AppSettings::ColoredHelp"))]
in structopt 0.2

@dpc
Copy link
Author

dpc commented Aug 24, 2019

I will try that!

@dpc
Copy link
Author

dpc commented Aug 24, 2019

@CreepySkeleton I don't thin 0.3 is release yet, BTW, but 0.2 version works like a charm.

@dpc dpc closed this as completed Aug 24, 2019
@CreepySkeleton
Copy link
Collaborator

CreepySkeleton commented Aug 24, 2019

@dpc Yeah, 0.3 is upcoming, I hope we'll manage to release it by the end of month, it'll make a lot of things easier. Just so you know: clap has a very rich API, and you can use any method from App and Arg via #[structopt(raw(method = "args"))] in 0.2 or directly in 0.3, like this #[structopt(method(args))].

P.S I wonder what a program with over a hundred subcommands could possibly be?

@dpc
Copy link
Author

dpc commented Aug 24, 2019

I exaggerated, but in cargo-crev keeps growing in subcomands, because everything is <verb> <noun> [<qualifier>].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement We would love to have this feature! Feel free to supply a PR
Projects
None yet
Development

No branches or pull requests

3 participants