urfave-cli/app_test.go
2013-07-20 15:50:13 -07:00

25 lines
427 B
Go

package cli_test
import (
"fmt"
"github.com/codegangsta/cli"
"os"
)
func ExampleApp() {
// set args for examples sake
os.Args = []string{"greet", "--name", "Jeremy"}
app := cli.NewApp()
app.Name = "greet"
app.Flags = []cli.Flag{
cli.StringFlag{"name", "bob", "a name to say"},
}
app.Action = func(c *cli.Context) {
fmt.Printf("Hello %v\n", c.String("name"))
}
app.Run(os.Args)
// Output:
// Hello Jeremy
}