Skip to content

Commit 14320a8

Browse files
authored
Include default true bool flags in CLI flag mapping (#1376)
1 parent df50c7a commit 14320a8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/components/conversionlayer.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,16 @@ func fillFlagMaps(c *Context, baseContext *cli.Context, originalFlags []Flag) er
416416
c.stringFlags[stringFlag.Name] = finalValue
417417
}
418418
}
419-
if boolFlag, ok := flag.(BoolFlag); ok && baseContext.IsSet(boolFlag.Name) {
420-
c.boolFlags[boolFlag.Name] = getValueForBoolFlag(boolFlag, baseContext)
419+
if boolFlag, ok := flag.(BoolFlag); ok {
420+
val := getValueForBoolFlag(boolFlag, baseContext)
421+
// Only store the flag if:
422+
// - The user explicitly set it, OR
423+
// - The resolved value is 'true' (e.g., default is true and user didn't override it)
424+
// This avoids adding unnecessary 'false' flags that aren't relevant.
425+
if baseContext.IsSet(boolFlag.Name) || val {
426+
// Store the flag and its resolved value in the context map
427+
c.boolFlags[boolFlag.Name] = val
428+
}
421429
}
422430
}
423431
return nil

0 commit comments

Comments
 (0)