This is an automated email from the ASF dual-hosted git repository. rpopma pushed a commit to branch GROOVY_2_5_X in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 66a91d830111717d2a19128f62380d44791a5e0a Author: Remko Popma <rem...@yahoo.com> AuthorDate: Wed Apr 29 15:38:37 2020 +0900 GROOVY-9519: bugfix: savedTypeOptions use longest option name as key (cherry picked from commit af8b21e475043673548f39dfaa5a1b30fd744d01) --- .../src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy b/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy index 4fac7c1..4f9f2a4 100644 --- a/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy +++ b/subprojects/groovy-cli-picocli/src/main/groovy/groovy/cli/picocli/OptionAccessor.groovy @@ -126,8 +126,13 @@ class OptionAccessor { if (parseResult.commandSpec().findOption(name)) { // requested option was not matched: return its default def option = parseResult.commandSpec().findOption(name) def result = option.value - Class userSpecifiedType = savedTypeOptions[name]?.type // GROOVY-9519: zero default for non-Boolean type options should not be converted to false + + // GROOVY-9519: zero default for non-Boolean type options should not be converted to false + def longOpt = option.longestName() + longOpt = longOpt?.startsWith("--") ? longOpt.substring(2) : longOpt + Class userSpecifiedType = savedTypeOptions[longOpt]?.type if (userSpecifiedType && Boolean != userSpecifiedType) { return result } + return result ? result : false } if (name.size() > 1 && name.endsWith('s')) { // user wants multi-value result