go-options

Stars
13

go-options

Easily way to get command line flags

Usage

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)
	}
}

Installation

go get github.com/mattn/go-options

License

MIT: http://mattn.mit-license.org/2013

Author

Yasuhiro Matsumoto ([email protected])

Badges
Extracted from project README
Build Status Coverage Status