Exemple #1
0
func main() {
	defer glog.Flush()
	flag.Parse()
	actions, err := fileToActions(filename)
	if err != nil {
		fmt.Println(err)
		return
	}

	if len(os.Args) <= 1 {
		fmt.Println("cmds needs at least one argument\n")
		fmt.Println("available commands:\n")
		for name := range actions {
			fmt.Printf("  %s\n", name)
		}
		return
	}

	for name, a := range actions {
		core.Action(name, a)
	}

	res, err := local.Run(&action.Action{Name: os.Args[1]})
	if res != nil {
		res = mapBytes(res)
		printMap(res, 1)
		fmt.Printf("\n")
	}
	if err != nil {
		fmt.Printf("ERROR %v\n", err)
	} else {
		fmt.Println("OK")
	}
}
Exemple #2
0
// RunAction - Runs action.
func (cmd *Command) RunAction(ctx action.Map) (action.Map, error) {
	// Get command action
	a := cmd.Action(ctx)
	// Run it
	return local.Run(a)
}
Exemple #3
0
// Run - actions.run - runs action using `name` and `ctx` from context.
func Run(ctx action.Map) (action.Map, error) {
	a := mapToAction(ctx)
	return local.Run(a)
}