A command line interface framework.
$ go get -u github.com/hattya/go.cli
package main
import (
"os"
"github.com/hattya/go.cli"
)
var app = cli.NewCLI()
func main() {
app.Version = "1.0"
app.Usage = "<options> hello"
app.Add(&cli.Command{
Name: []string{"hello"},
Action: func(ctx *cli.Context) error {
ctx.UI.Println("Hello World!")
return nil
},
})
if err := app.Run(os.Args[1:]); err != nil {
if _, ok := err.(cli.FlagError); ok {
os.Exit(2)
}
os.Exit(1)
}
}
go.cli is distributed under the terms of the MIT License.