// WithStdout sets the standard output writer of the command
978328
func WithStdout(writer io.Writer) func(*icmd.Cmd) func() {
	return func(cmd *icmd.Cmd) func() {
		cmd.Stdout = writer
		return nil
	}
}
318738
func ScanPrintStdout(scanner *bufio.Scanner, print bool) {
	for scanner.Scan() {
		if print {
			fmt.Fprintf(os.Stdout, "%s\n", scanner.Text())
		}
	}
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
}
932545
func RunCommandWithReaderAndWriters(inReader io.Reader, outWriter, errWriter io.Writer, name string, args ...string) error {
	cmd := exec.Command(name, args...)
	cmd.Stdin = inReader
	cmd.Stdout = outWriter
	cmd.Stderr = errWriter
	return cmd.Run()
}
45216
func (builder *SearchCommandBuilder) WithStart(start uint32) *SearchCommandBuilder {
	builder.protobuf.Start = &start
	return builder
}
460779
func (c *Cmd) StdoutMatches(regex string) bool {
	c.validate()
	re := regexp.MustCompile(regex)
	return re.MatchString(c.Stdout())
}
260124
func WithStd(cfg config.Log) Log {
	return stdLogger{Logger: log.New(cfg.Converted.Writer, cfg.Converted.Prefix, 0)}
}
40637
func ExitWithStatus(status *NagiosStatus) {
	fmt.Fprintln(os.Stdout, valMessages[status.Value], status.Message)
	os.Exit(int(status.Value))
}
1356309
func NewStdoutWriter(out io.Writer) io.Writer {
	return &streamWriter{Writer: out, lineFormat: func(buf []byte) string {
		return string(buf)
	}}
}
718048
func (builder *TsQueryCommandBuilder) WithStreaming(streaming bool) *TsQueryCommandBuilder {
	builder.protobuf.Stream = &streaming
	return builder
}
105117
func (e *ExecRunner) CombinedOutput(cmd string) (string, error) {
	var b bytes.Buffer
	err := e.CombinedOutputTo(cmd, &b)
	if err != nil {
		return "", errors.Wrapf(err, "running command: %s\n output: %s", cmd, b.Bytes())
	}
	return b.String(), nil

}
945988
func (out *Output) Printf(format string, a ...interface{}) error {
	out.mu.Lock()
	defer out.mu.Unlock()
	s := fmt.Sprintf(format, a...)
	_, err := out.wd.Write([]byte(s))
	return err
}
627532
func newPrettyStdout(w io.Writer) *prettyStdout {
	return &prettyStdout{
		writer: w,
		buffer: bytes.NewBuffer([]byte{}),
	}
}
546312
func PrintErrorWithCommand(err error, flagMap map[string]reflect.StructField, defaultValMap map[string]reflect.Value, parsers map[reflect.Type]parse.Parser, cmd *Command, subCmd []*Command) error {
	if err != flag.ErrHelp {
		fmt.Printf("Error here : %s\n", err)
	}

	if errHelp := PrintHelpWithCommand(flagMap, defaultValMap, parsers, cmd, subCmd); errHelp != nil {
		return errHelp
	}

	return err
}
480635
func WithTimeout(timeout time.Duration, prog string, args ...string) *Cmd {
	ctx, cancel := context.WithTimeout(context.Background(), timeout)
	cmd := CommandContext(ctx, prog, args...)
	cmd.cancelFn = cancel
	return cmd
}
637161
func (builder *StoreValueCommandBuilder) WithW(w uint32) *StoreValueCommandBuilder {
	builder.protobuf.W = &w
	return builder
}
538393
func (ex *ExitStatus) IsTimedOut() bool {
	return ex.typ == exitTypeTimedOut || ex.typ == exitTypeKilled
}
107819
func getOutput(filename string) (*os.File, error) {
	if filename == "-" || filename == "" {
		return os.Stdout, nil
	}

	return os.Create(filename)
}