command: UIOutput is functinal
This commit is contained in:
parent
6d9463bfa8
commit
b2342866c9
|
@ -1,6 +1,8 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/mitchellh/colorstring"
|
||||
)
|
||||
|
@ -9,7 +11,18 @@ import (
|
|||
type UIOutput struct {
|
||||
Colorize *colorstring.Colorize
|
||||
Ui cli.Ui
|
||||
|
||||
once sync.Once
|
||||
ui cli.Ui
|
||||
}
|
||||
|
||||
func (u *UIOutput) Output(v string) {
|
||||
u.once.Do(u.init)
|
||||
u.ui.Output(v)
|
||||
}
|
||||
|
||||
func (u *UIOutput) init() {
|
||||
// Wrap the ui so that it is safe for concurrency regardless of the
|
||||
// underlying reader/writer that is in place.
|
||||
u.ui = &cli.ConcurrentUi{Ui: u.Ui}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue