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

Default descriptionKey for options and parameters #638

Closed
Mikusch opened this issue Feb 23, 2019 · 3 comments
Closed

Default descriptionKey for options and parameters #638

Mikusch opened this issue Feb 23, 2019 · 3 comments

Comments

@Mikusch
Copy link

Mikusch commented Feb 23, 2019

In applications with a lot of commands, localizing argument descriptions is very tedious because you need to explicitly set descriptionKey on each option and positional parameter you wish to localize and ensure that the names match up with the keys in the resource bundle.

I propose a fallback resource bundle key that takes effect when both the description and descriptionKey attributes in @Option and @Parameters have not been set, similar to how the usage message already has pre-defined keys such as mycommand.usage.customSynopsis.

For a command purge with the --verbose option and files parameter the keys could be named git.option.--verbose or git.option.verbose and git.param.files.

If no mapping to that fallback key exists, it should do the same as it currently does when descriptionKey is missing and read the description attribute instead.

@remkop
Copy link
Owner

remkop commented Feb 23, 2019

This is already implemented. Please see the javadoc for @Option.descriptionkey and @Parameters.descriptionkey.

For options the fallback key is any option name without the leading dashes, for example:

# For option --verbose
verbose = Show more detail during execution. May be specified multiple times for increasing verbosity. 

For positional parameters the fallback key is the paramLabel [ index ], for example:

# For @Parameters(paramLabel="FILES") File[];
FILES[0..*] = The Files to process.

@Mikusch
Copy link
Author

Mikusch commented Feb 23, 2019

Interesting, I wasn't aware of the syntax for positional parameters.

You may want to add that to the example resource file over at https://picocli.info/#_example_resource_bundle.

I apologize for making this issue, have a good evening.

@Mikusch Mikusch closed this as completed Feb 23, 2019
@remkop remkop added this to the 4.0 milestone Feb 23, 2019
@remkop
Copy link
Owner

remkop commented Feb 24, 2019

That's a good idea, I added some text to that section just now. Thanks for the suggestion!

remkop added a commit that referenced this issue Feb 24, 2019
@remkop remkop modified the milestones: 4.0, 4.0-alpha-1 Mar 30, 2019
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