Пример #1
0
func NewCommand(sysCommand system.Command) *Command {
	command := sysCommand.Command()
	exitStatus, _ := sysCommand.ExitStatus()
	stdout, _ := sysCommand.Stdout()
	stderr, _ := sysCommand.Stderr()
	return &Command{
		Command:    command,
		ExitStatus: exitStatus.(string),
		Stdout:     readerToSlice(stdout),
		Stderr:     readerToSlice(stderr),
	}
}
Пример #2
0
func NewCommand(sysCommand system.Command, ignoreList []string) *Command {
	command := sysCommand.Command()
	exitStatus, _ := sysCommand.ExitStatus()
	c := &Command{
		Command:    command,
		ExitStatus: exitStatus.(string),
		Stdout:     []string{},
		Stderr:     []string{},
	}

	if !contains(ignoreList, "stdout") {
		stdout, _ := sysCommand.Stdout()
		c.Stdout = readerToSlice(stdout)
	}
	if !contains(ignoreList, "stderr") {
		stderr, _ := sysCommand.Stderr()
		c.Stderr = readerToSlice(stderr)
	}

	return c
}
Пример #3
0
func NewCommand(sysCommand system.Command, config util.Config) (*Command, error) {
	command := sysCommand.Command()
	exitStatus, err := sysCommand.ExitStatus()
	c := &Command{
		Command:    command,
		ExitStatus: exitStatus.(string),
		Stdout:     []string{},
		Stderr:     []string{},
		Timeout:    config.Timeout,
	}

	if !contains(config.IgnoreList, "stdout") {
		stdout, _ := sysCommand.Stdout()
		c.Stdout = readerToSlice(stdout)
	}
	if !contains(config.IgnoreList, "stderr") {
		stderr, _ := sysCommand.Stderr()
		c.Stderr = readerToSlice(stderr)
	}

	return c, err
}