Fix issue with negatable flag being negated twice (#171)
This commit is contained in:
+6
-6
@@ -635,12 +635,7 @@ func (c *Context) Apply() (string, error) {
|
||||
panic("unsupported path ?!")
|
||||
}
|
||||
if value != nil {
|
||||
v := c.getValue(value)
|
||||
if value.Flag != nil && value.Flag.Negated {
|
||||
v.SetBool(!v.Bool())
|
||||
}
|
||||
|
||||
value.Apply(v)
|
||||
value.Apply(c.getValue(value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,6 +668,11 @@ func (c *Context) parseFlag(flags []*Flag, match string) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
if flag.Negated {
|
||||
value := c.getValue(flag.Value)
|
||||
value.SetBool(!value.Bool())
|
||||
flag.Value.Apply(value)
|
||||
}
|
||||
c.Path = append(c.Path, &Path{Flag: flag})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user