Don't display placeholder for counters.

Fixes #164.
This commit is contained in:
Alec Thomas
2021-04-18 10:05:26 +10:00
parent 8d859b918f
commit 2e611623a7
2 changed files with 24 additions and 17 deletions
+6 -1
View File
@@ -305,6 +305,11 @@ func (v *Value) IsBool() bool {
return v.Target.Kind() == reflect.Bool
}
// IsCounter returns true if the value is a counter.
func (v *Value) IsCounter() bool {
return v.Tag.Type == "counter"
}
// Parse tokens into value, parse, and validate, but do not write to the field.
func (v *Value) Parse(scan *Scanner, target reflect.Value) (err error) {
defer func() {
@@ -384,7 +389,7 @@ func (f *Flag) String() string {
if f.Short != 0 {
out = fmt.Sprintf("-%c, %s", f.Short, out)
}
if !f.IsBool() {
if !f.IsBool() && !f.IsCounter() {
out += "=" + f.FormatPlaceHolder()
}
return out