3 Cli - A tool for building command line app

github.com godoc.org goreportcard.com posted by mkideal 2926 days ago  

Easy to use command line interface tool written in golang, open-source on github

package main

import (

"github.com/mkideal/cli"

)

type argT struct {

Help bool `cli:"h,help" usage:"display help information"`

Name string `cli:"name" usage:"your name" dft:"world"`

}

func main() {

cli.Run(&argT{}, func(ctx *cli.Context) error {

argv := ctx.Argv().(*argT)

if argv.Help {

ctx.String(ctx.Usage())

} else {

ctx.String("Hello, %s! \n", argv.Name)

}

return nil

})

}

Register to comment or vote on this story