Ejemplo n.º 1
0
func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
	var context *cli.Context

	a := cli.NewApp()
	a.Commands = []cli.Command{
		{
			Name: "foo",
			Action: func(c *cli.Context) {
				context = c
			},
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "lang",
					Value: "english",
					Usage: "language for the greeting",
				},
			},
			Before: func(_ *cli.Context) error { return nil },
		},
	}
	a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})

	expect(t, context.Args().Get(0), "abcd")
	expect(t, context.String("lang"), "spanish")
}
Ejemplo n.º 2
0
func doMain(c *cli.Context) {

	steps.Datas = parsers.ParseYaml(c.Args())
	for _, data := range steps.Datas {
		steps.Init(c.String("remote"), data)
	}

}
Ejemplo n.º 3
0
func doBefore(c *cli.Context) error {

	args := c.Args()

	if len(args) == 0 {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}
	for _, arg := range args {
		ok, _ := regexp.MatchString(`\.ya?ml$`, arg)
		if !ok {
			fmt.Println(arg + " is not yaml file.")
			os.Exit(2)
		}
	}

	return nil
}