Skip to content

crdx/duckopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duckopt

duckopt is a docopt wrapper library for Go.

Installation

go get crdx.org/duckopt/v2

Usage

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

Contributions

Open an issue or send a pull request.

Licence

GPLv3.