Ejemplo n.º 1
0
func TestLines(t *testing.T) {
	cmd := sh.Command{"echo 12; echo 34"}
	out, _ := cmd.Lines()
	if len(out) != 2 {
		t.Errorf("command(%s) should output 2 line, but is: %#v", cmd.Text(), out)
	}
}
Ejemplo n.º 2
0
func Ps() []PsOutput {
	cmd := sh.Command{"docker ps -a"}

	lines, _ := cmd.Lines()
	var reader = sh.NewReader(lines, PsOutput{})

	var status []PsOutput
	status = make([]PsOutput, 0)

	for {
		var s PsOutput
		err := sh.Unmarshal(reader, &s)

		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
		status = append(status, s)
	}
	return status
}