awesome-patterns/playground/factory/urfavecli/main.go
2020-05-11 18:08:58 +08: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)
}