awesome-patterns/urfavecli/main.go

28 lines
428 B
Go
Raw Normal View History

2017-12-03 08:50:40 +03:00
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)
}