duckopt is a docopt wrapper library for Go.
go get crdx.org/duckopt/v2
import (
"fmt"
"crdx.org/duckopt/v2"
)
func getUsage() string {
return `
Usage:
$0 [options] run <task>
Options:
-v, --verbose Be verbose
`
}
type Opts struct {
Command bool `docopt:"run"`
Arg string `docopt:"<task>"`
Verbose bool `docopt:"--verbose"`
}
func main() {
opts := duckopt.MustBind[Opts](getUsage(), "$0")
fmt.Printf("%+v\n", opts)
}
Open an issue or send a pull request.