urfave-cli/app_test.go

25 lines
427 B
Go
Raw Normal View History

2013-07-20 22:50:13 +00:00
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
}