Esempio n. 1
0
File: hg.go Progetto: hgoo/hg
func main() {
	flag.Usage = usage
	flag.Parse()
	log.SetFlags(0)
	args := flag.Args()
	if len(args) < 1 {
		usage()
	}

	if args[0] == "help" {
		help(args[1:])
		return
	}
	for _, cmd := range commands {
		if cmd.Name() == args[0] && cmd.Run != nil {
			cmd.Flag.Usage = func() { cmd.Usage() }
			if cmd.CustomFlags {
				args = args[1:]
			} else {
				cmd.Flag.Parse(args[1:])
				args = cmd.Flag.Args()
			}
			os.Exit(cmd.Run(cmd, args))
		}
	}
}
Esempio n. 2
0
func Test_RunApp(t *testing.T) {
	cmd := []*cmd.Command{cmd.CmdRun}[0]
	cmd.Run(cmd, []string{"hbox-api"})
}