Support repeating composite arguments (was: Parameter options/modifiers)
See original GitHub issuePicocli supports mixing options and parameters: http://picocli.info/#_mixing_options_and_positional_parameters
I would like to know what options have been specified before certain parameter. Consider such command:
print --paper A4 A.pdf --count 3 B.pdf --rotate left C.pdf -- D.pdf --rotate right E.pdf
Where:
--paper
is an global option,--count
and--rotate
are “local” options, or parameter modifiers,--
reset local options.
So, that command would evaluate to:
- globals:
paper = A4
, - parameter
A.pdf
:count = default, rotate = default
, - parameter
B.pdf
:count = 3, rotate = default
, - parameter
C.pdf
:count = 3, rotate = left
, - parameter
D.pdf
:count = default, rotate = default
, - parameter
E.pdf
:count = default, rotate = right
.
Is there support for such things in picocli?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Repeating options with sub-options/arguments #635 - GitHub
I would like to add an option multiple times and add sub-options/parameters to it. In my scenario, I have a viewer application and, ......
Read more >CommandLine.ArgGroup (picocli 4.7.0 API)
By default, options and positional parameters in a group are mutually exclusive. ... the usage help message. define composite repeating argument groups.
Read more >Search - FHIR v5.0.0-cibuild
Search parameter definitions MAY include a list of allowed modifiers in the SearchParameter.code element, which is bound to the search-modifier-code value set.
Read more >Contracts — Solidity 0.8.17 documentation
Modifiers are inheritable properties of contracts and may be overridden by derived contracts, but only if they are marked virtual . For details,...
Read more >Compose modifiers - Jetpack - Android Developers
Jetpack Compose provides a list of built-in modifiers to help you decorate or augment a composable. Here are some common modifiers you'll use...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Picocli 4.0.0-alpha-1 has been released which includes support for repeating composite groups. See https://picocli.info/#_argument_groups for details.
Please try this and provide feedback. We can still make changes.
What do you think of the annotations API? What about the programmatic API? Does it work as expected? Are the input validation error messages correct and clear? Is the documentation clear and complete? Anything you want to change or improve? Any other feedback?
That’s the synopsis, but the invocation currently is:
In case it keeps working like this, then the answer to your question depends on the implementation of how arguments are referenced after parsing:
If these composite option values would have to be predefined (ie. a class with declared fields), then it would be useful and feasible to have optional fields (being referable by name). However, in my use case I prefer to leave to the composition unbounded (ie. an array of arbitrary number of types of mandatory parameter values). This is because I’m generating the composite signatures in runtime using reflection.
To illustrate, I prefer:
over:
Of course, you could work with a Map here:
In this case the parsed arguments can be referenced by name but also generated by name in run time, in which case optional values are workable again. Without named arguments, it will become impossible to know which parameters of a java
Method
should be null.In general though, I have to add that I don’t have many optional parameters, because that would imply that there is a different need than the API provides and I would simply add an overloaded more succinct version with that parameter left out.