question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for IDefaultValueProvider

See original GitHub issue

Add 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:27 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Sep 10, 2018

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 with IDefaultProvider.defaultValue(ArgSpec)).

(Also need to update the Javadoc for these ArgSpec methods to clarify where the values come from.)

1reaction
remkopcommented, Sep 9, 2018

I just realized we forgot about ${DEFAULT-VALUE} replacement in the usage help description. That is tricky because the ArgSpec does not have a reference to the default value provider… I guess we need to add that, or a reference to the CommandSpec, when an ArgSpec is added to the CommandSpec.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found