awesome-patterns/urfavecli/main.go
2017-12-03 15:50:40 +10:00

28 lines
428 B
Go

package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "hello_cli"
app.Usage = "Print hello world"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "name, n",
Value: "World",
Usage: "Who to say hello to.",
},
}
app.Action = func(c *cli.Context) error {
name := c.GlobalString("name")
fmt.Printf("Hello %s!\n", name)
return nil
}
app.Run(os.Args)
}