|
|
|
|
@ -14,6 +14,13 @@ type Ui interface {
|
|
|
|
|
Error(format string, a ...interface{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrefixedUi is a UI that wraps another UI implementation and adds a
|
|
|
|
|
// prefix to all the messages going out.
|
|
|
|
|
type PrefixedUi struct {
|
|
|
|
|
Prefix string
|
|
|
|
|
Ui Ui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The ReaderWriterUi is a UI that writes and reads from standard Go
|
|
|
|
|
// io.Reader and io.Writer.
|
|
|
|
|
type ReaderWriterUi struct {
|
|
|
|
|
@ -21,6 +28,14 @@ type ReaderWriterUi struct {
|
|
|
|
|
Writer io.Writer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *PrefixedUi) Say(format string, a ...interface{}) {
|
|
|
|
|
u.Ui.Say(fmt.Sprintf("%s: %s", u.Prefix, format), a...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *PrefixedUi) Error(format string, a ...interface{}) {
|
|
|
|
|
u.Ui.Error(fmt.Sprintf("%s: %s", u.Prefix, format), a...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (rw *ReaderWriterUi) Say(format string, a ...interface{}) {
|
|
|
|
|
output := fmt.Sprintf(format, a...)
|
|
|
|
|
log.Printf("ui: %s", output)
|
|
|
|
|
|