Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ func (e *Executor) parseTaskFlagsIntoMap(taskName string, flags []string) map[st
flagValErrMsg := fmt.Sprintf("The type for the `%s` flag is `%s`. Please use `%s`", key, taskFlag.ValueType, flagTypeToGetter[taskFlag.ValueType])

// Bare boolean flags (e.g. --dry-run without =value) mean true.
if val == "" && taskFlag.ValueType == BoolTypeFlag {
// len(splitFlag)==1 means no "=" was present; len(splitFlag)==2 with
// empty val means "--flag=" which is an explicit empty value, not bare.
if val == "" && len(splitFlag) == 1 && taskFlag.ValueType == BoolTypeFlag {
val = "true"
}

Expand Down
5 changes: 5 additions & 0 deletions executor_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func TestParseTaskOptionsListToMap(t *testing.T) {
flagArgs: []string{"-f"},
expectedFlagFVal: boolPtr(true),
},
{
description: "Explicit empty bool flag (--flag=) should not default to true",
flagArgs: []string{"-f="},
expectFlagFNil: true,
},
{
description: "Should store Default values for all flags and Value nil when no args are passed",
flagArgs: []string{},
Expand Down
Loading