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

Enhancement: printHelpIfRequested should support a custom ColorScheme #433

Closed
bbottema opened this issue Aug 5, 2018 · 6 comments
Closed
Milestone

Comments

@bbottema
Copy link
Contributor

bbottema commented Aug 5, 2018

The documentation indicates you can use a custom ColorScheme like so:

CommandLine.usage(annotatedObject, System.out, colorScheme);

However, I have been unable to find a way to use a custom color scheme using printHelpIfRequested:

CommandLine.printHelpIfRequested(pr.asCommandLineList(), out, err, Ansi.ON);

Is there a way to achieve this? Specifically I wish to assign a color to all subcommands listed under "Command:". UsageMessageSpec also doesn't allow this customization as far as I can see.

@remkop
Copy link
Owner

remkop commented Aug 5, 2018

You can use the system properties described in the manual.

System Properties to Override the Color Scheme

picocli.color.commands
picocli.color.options
picocli.color.parameters
picocli.color.optionParams

For example:

java -Dpicocli.color.options=blink,blue -Dpicocli.color.parameters=reverse com.app.Main

System property values may specify multiple comma separated styles.

@bbottema
Copy link
Contributor Author

bbottema commented Aug 5, 2018

Ahh, missed that one. Thanks, that solves it for me.

For a consistent API though, I would still argue for the above case. It feels a little strange to me that only CommandLine.usage(..) accepts a custom ColorScheme.

@remkop
Copy link
Owner

remkop commented Aug 5, 2018

Let's leave this ticket open and I'll get to it at some point.
Unless you feel like providing a pull request to get it done faster. :-)

@remkop
Copy link
Owner

remkop commented Aug 17, 2018

Fixed in master. Please verify.
If you have any code that could be added to picocli's unit tests to verify this, that would be very helpful.

bbottema added a commit to bbottema/picocli that referenced this issue Aug 17, 2018
@bbottema
Copy link
Contributor Author

Yep works, added a junit test for you as well.

@remkop
Copy link
Owner

remkop commented Aug 18, 2018

Thanks for the unit test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants