Add negatable tag to set a bool to be negatable.

If negatable, add `--[no-]` prefix to help.
This commit is contained in:
Joe Schmitt
2021-02-18 10:55:55 -05:00
committed by Alec Thomas
parent 2a0d7af9c5
commit 2fdddc4f51
7 changed files with 34 additions and 5 deletions
+1 -1
View File
@@ -652,7 +652,7 @@ func (c *Context) parseFlag(flags []*Flag, match string) (err error) {
}
// Found a matching flag.
c.scan.Pop()
if flag.Value.IsBool() && match == neg {
if match == neg && flag.Tag.Negatable {
flag.Negated = true
}
err := flag.Parse(c.scan, c.getValue(flag.Value))