diff options
| author | gonix <[email protected]> | 2017-10-05 23:42:34 +0300 |
|---|---|---|
| committer | Eric Paris <[email protected]> | 2017-10-05 16:42:34 -0400 |
| commit | 2c300e72a98b4351617d9b927d2d2860ece8ee24 (patch) | |
| tree | 0de53385665dfc8fa6bb8ddf49c5facf52d602b9 /count.go | |
| parent | be7121dd7a937a85e1e4b1ddda6a3edce3466110 (diff) | |
Fixing Count flag usage string (#141)
Diffstat (limited to 'count.go')
| -rw-r--r-- | count.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -11,13 +11,13 @@ func newCountValue(val int, p *int) *countValue { } func (i *countValue) Set(s string) error { - v, err := strconv.ParseInt(s, 0, 64) - // -1 means that no specific value was passed, so increment - if v == -1 { + // "+1" means that no specific value was passed, so increment + if s == "+1" { *i = countValue(*i + 1) - } else { - *i = countValue(v) + return nil } + v, err := strconv.ParseInt(s, 0, 0) + *i = countValue(v) return err } @@ -54,7 +54,7 @@ func (f *FlagSet) CountVar(p *int, name string, usage string) { // CountVarP is like CountVar only take a shorthand for the flag name. func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) { flag := f.VarPF(newCountValue(0, p), name, shorthand, usage) - flag.NoOptDefVal = "-1" + flag.NoOptDefVal = "+1" } // CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set |
