Skip to content

Commit 0b88529

Browse files
author
Alexis Destrez
committed
Allow bool flag to don't have value
1 parent 1ff4952 commit 0b88529

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mapper/spf13/cobra/flag.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88

99
func setCobraFlagsFromCLIFlags(set *pflag.FlagSet, flags []cli.Flag) {
1010
for _, flag := range flags {
11-
set.VarP(&flagValuer{flag}, flag.LongName(), flag.ShortName(), flag.Description())
11+
fset := set.VarPF(&flagValuer{flag}, flag.LongName(), flag.ShortName(), flag.Description())
12+
if _, isBool := flag.Destination().(*bool); isBool {
13+
fset.NoOptDefVal = "true"
14+
}
1215
}
1316
}
1417

0 commit comments

Comments
 (0)