Skip to content

mattn/go-options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-options

Build Status Coverage Status

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 (mattn.jp@gmail.com)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages