示例#1
0
文件: apt.go 项目: hoangclinh/go_ne
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	var commands []shared.Command

	update := shared.ExtractBool(args.Options["update"])
	if update {
		commands = append(commands, updateCommand())
	}

	commands = append(commands, installCommand(args))

	*reply = shared.NewResponse(commands...)

	return nil
}
示例#2
0
文件: ping.go 项目: hoangclinh/go_ne
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	cmd := []string{
		"ping",
	}

	if count, ok := args.Options["count"]; ok {
		c := count.(float64)
		cmd = append(cmd, fmt.Sprintf("-c %v", c))
	}

	cmd = append(cmd, shared.ExtractString(args.Options["url"]))
	*reply = shared.NewResponse(shared.NewCommand(strings.Join(cmd, " ")))

	return nil
}
示例#3
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	directory := args.Options["directory"].(string)

	a := []string{
		"git",
		"clone",
		args.Options["repo"].(string),
		directory,
	}

	cmd := shared.NewCommand(strings.Join(a, " "))
	cmd.Unless(shared.DirectoryExists(directory))

	*reply = shared.NewResponse(cmd)

	return nil
}
示例#4
0
func (t *Command) Execute(args shared.Args, reply *shared.Response) error {
	*reply = shared.NewResponse(shared.NewCommand("whoami"))

	return nil
}