Add support for IDefaultValueProvider
See original GitHub issueAdd support for IDefaultValueProvider
on @Command
and potentially on individual @Option
and @Parameters
.
See discussion under #261.
Proposed API:
interface IDefaultValueProvider {
/** Returns the default value for an option or positional parameter or {@code null}.
* The returned value is converted to the type of the option/positional parameter
* via the same type converter used when populating this option/positional
* parameter from a command line argument.
* @param argSpec the option or positional parameter, never {@code null}
* @return the default value for the option or positional parameter, or {@code null} if
* this provider has no default value for the specified option or positional parameter
*/
String defaultValue(ArgSpec argSpec);
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:27 (27 by maintainers)
Top Results From Across the Web
Mock customization - Unit Testing in C#
By default, Moq supports developers by allowing them to create unit tests without forcing ... var mock = new Mock<IService> { DefaultValueProvider =...
Read more >Creating Addins - Cake Build
Start by creating a new class library project and add a reference to the Cake. ... Cake supports the automatic import of namespaces...
Read more >picocli - a mighty tiny command line interface
Picocli 4.6 adds support for inheriting @Command attributes with the scope = ScopeType.INHERIT annotation. Commands with this scope have their @Command ...
Read more >Unable to load System.Threading.Tasks.Extensions
1. We are trying to added PostgreSQL support for the project. Using Nuget, I have installed 4.0.4 npgsql to the project. Under references,...
Read more >WSDL to Java - Apache CXF
Currently supports only JAXWS frontend and a "jaxws21" frontend to ... You may need to add a dependency to cxf-rt-binding-soap for this flag...
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
I’ve given it some thought and I am leaning towards changing
ArgSpec.defaultValueString()
to return the value from the default provider (if one exists).That meets the first goal (description text containing ${DEFAULT-VALUE} should be rendered with the default value), and at the same time allows application authors to distinguish between the default value that was programmatically set on an option (can be obtained with
ArgSpec.defaultValue()
) and the default value from the provider (can be obtained withIDefaultProvider.defaultValue(ArgSpec)
).(Also need to update the Javadoc for these ArgSpec methods to clarify where the values come from.)
I just realized we forgot about
${DEFAULT-VALUE}
replacement in the usage help description. That is tricky because theArgSpec
does not have a reference to the default value provider… I guess we need to add that, or a reference to theCommandSpec
, when anArgSpec
is added to theCommandSpec
.