Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of parsing a repeated argument like '-vvv' with kingpin
package main
import (
"fmt"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
verbose = kingpin.Flag("verbose", "Enable verbose mode.").Short('v').Counter()
)
func main() {
kingpin.Version("0.0.1")
kingpin.Parse()
fmt.Printf("verbose=%v\n", *verbose)
}
@hnakamur
Copy link
Author

hnakamur commented Jan 7, 2016

$ go run kingpin_repeat_arg_example.go
verbose=0
$ go run kingpin_repeat_arg_example.go -v
verbose=1
$ go run kingpin_repeat_arg_example.go -vv
verbose=2
$ go run kingpin_repeat_arg_example.go -vvv
verbose=3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment