Easily way to get command line flags
var opts = options.Options{
{"h", false, "Show Help"},
{"verbose", false, "Verbose output"},
}
if err := options.Parse(opts); err != nil || opts.Bool("h") {
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
opts.Usage()
}
for i, arg := range options.Args {
if opts.Bool("verbose") {
fmt.Printf("argument %d is %s\n", i+1, arg)
} else {
fmt.Println(arg)
}
}
go get github.com/mattn/go-options
MIT: http://mattn.mit-license.org/2013
Yasuhiro Matsumoto ([email protected])