File: ui_writer.go

package info (click to toggle)
golang-github-mitchellh-cli 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 280 kB
  • sloc: makefile: 16
file content (18 lines) | stat: -rw-r--r-- 349 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package cli

// UiWriter is an io.Writer implementation that can be used with
// loggers that writes every line of log output data to a Ui at the
// Info level.
type UiWriter struct {
	Ui Ui
}

func (w *UiWriter) Write(p []byte) (n int, err error) {
	n = len(p)
	if n > 0 && p[n-1] == '\n' {
		p = p[:n-1]
	}

	w.Ui.Info(string(p))
	return n, nil
}