showDefaultValues=true plus defaultValueProvider does not render defaultValues in usage help
See original GitHub issueSpecifying the default value of an option via an IDefaultValueProvider
and setting showDefaultValues = true
does not display the default vaulue as part of the standard usage help.
Example Code:
@Command(name = "foo", //
mixinStandardHelpOptions = true, //
defaultValueProvider = FooCommandDefaultValueProvider.class, //
showDefaultValues = true, //
)
public class FooCommand implements Runnable {
public static class FooCommandDefaultValueProvider implements IDefaultValueProvider {
@Override
public String defaultValue(final ArgSpec argSpec) throws Exception {
if ("DURATION".equals(argSpec.paramLabel())) {
return "1200";
}
return null;
}
}
@Option( //
names = {"-d", "--duration"}, paramLabel = "DURATION", //
description = { "The duration, in seconds." }, //
arity = "1", //
required = false //
)
protected Integer duration;
}
Only when I additionally set @Option(showDefaultValue=Help.Visibility.ALWAYS)
for the respective option the value is displayed or when I explicitly set a default value directly via @Option(defaultValue="1200")
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
DefaultValues of react-hook-form is not setting the values to ...
The problem is that during the first render, users is the useState hook's initial value, which is null . The value only changes...
Read more >Generated defaultValues are not applied after first render #1558
I have a form that includes controlled components (several Material-UI checkboxes). By specifying defaultValues, I am able to reset the form ...
Read more >useForm - watch - Simple React forms validation
When defaultValue is not defined, the first render of watch will return undefined because it is called before register . It's recommend to...
Read more >Linux useradd command help and examples - Computer Hope
The default is to append the LOGIN name to BASE_DIR and use that as the login directory name. The directory HOME_DIR does not...
Read more >Change Command Default (CHGCMDDFT) - IBM
This procedure allows the user to use the original IBM-supplied command defaults when necessary and ensures that changes made to the copied commands...
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 3.9.3 has been released. This includes a fix for this issue.
Enjoy!
I found the cause. In
ArgSpec.internalShowDefaultValue(boolean)
the logic checks whether a default value exists, and this does not take the defaultValueProvider into account.I’ll have a fix for this shortly.