Skip to content

handlename/go-opts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-opts

Shortcut for package "flag".

Usage

code

package main

import (
    "fmt"

    "github.com/handlename/go-opts"
)

type myOpts struct {
    Name string `flag:"name" default:"alice" description:"your name"`
    Age  int    `flag:"age" default:"25" description:"your age"`
}

func main() {
    o := myOpts{}
    opts.Parse(&o)
    fmt.Println(o)
}

run

$ go run sample.go --name=bob
{bob 25}

$ go run sample/app.go --help
Usage of /var/folders/7r/p77s6hs55s1c7ch482_2m75w0000gn/T/go-build994360613/command-line-arguments/_obj/exe/app:
  -age=25: your age
  -name="alice": your name
exit status 2

Todo

Test...

Licence

MIT

Author

handlename

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages