Call executes the command, capturing its output. This is a helper for the common case where you want to run a command, capture all its output into a string and see if it succeeded.
(ctx context.Context)
| 174 | // This is a helper for the common case where you want to run a command, capture all its output into a string and |
| 175 | // see if it succeeded. |
| 176 | func (cmd Cmd) Call(ctx context.Context) (string, error) { |
| 177 | buf := &muxedBuffer{} |
| 178 | err := cmd.Capture(buf, buf).Run(ctx) |
| 179 | output := strings.TrimSpace(buf.buf.String()) |
| 180 | return output, err |
| 181 | } |
| 182 | |
| 183 | func (cmd Cmd) Format(f fmt.State, c rune) { |
| 184 | fmt.Fprint(f, cmd.Name) |