Closed suntong closed 8 years ago
Ok, but it will take a little bit of time.
NP. Just a wish that I might have it some day. No rush.
See commit c86f2c0 and example 030
package main
import (
"github.com/mkideal/cli"
)
type argT struct {
cli.Helper
V cli.Counter `cli:"v" usage:"count verbose"`
}
func main() {
cli.Run(new(argT), func(ctx *cli.Context) error {
argv := ctx.Argv().(*argT)
ctx.String("v=%d\n", argv.V.Value())
return nil
})
}
$ go run main.go -v
v=1
$ go run main.go -vv
v=2
$ go run main.go -v -v
v=2
:+1:
Can
cli
provide the accumulative option like what ssh does for verbose?I.e., the more
-v
are specified on the command line, the more verbose it will be. This will be good for other purpose like debug as well. So far my code look like this:To use it, I have to specify
-v 1
or-v 2
, a little bit inconvenient than specifying-v
or-v -v
.Thanks