Skip to content
No description, website, or topics provided.
Go
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample
LICENSE
README.md
opts.go

README.md

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

You can’t perform that action at this time.