aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/mitchellh/cli/ui_concurrent.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mitchellh/cli/ui_concurrent.go')
-rw-r--r--vendor/github.com/mitchellh/cli/ui_concurrent.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/cli/ui_concurrent.go b/vendor/github.com/mitchellh/cli/ui_concurrent.go
new file mode 100644
index 0000000..b4f4dbf
--- /dev/null
+++ b/vendor/github.com/mitchellh/cli/ui_concurrent.go
@@ -0,0 +1,54 @@
1package cli
2
3import (
4 "sync"
5)
6
7// ConcurrentUi is a wrapper around a Ui interface (and implements that
8// interface) making the underlying Ui concurrency safe.
9type ConcurrentUi struct {
10 Ui Ui
11 l sync.Mutex
12}
13
14func (u *ConcurrentUi) Ask(query string) (string, error) {
15 u.l.Lock()
16 defer u.l.Unlock()
17
18 return u.Ui.Ask(query)
19}
20
21func (u *ConcurrentUi) AskSecret(query string) (string, error) {
22 u.l.Lock()
23 defer u.l.Unlock()
24
25 return u.Ui.AskSecret(query)
26}
27
28func (u *ConcurrentUi) Error(message string) {
29 u.l.Lock()
30 defer u.l.Unlock()
31
32 u.Ui.Error(message)
33}
34
35func (u *ConcurrentUi) Info(message string) {
36 u.l.Lock()
37 defer u.l.Unlock()
38
39 u.Ui.Info(message)
40}
41
42func (u *ConcurrentUi) Output(message string) {
43 u.l.Lock()
44 defer u.l.Unlock()
45
46 u.Ui.Output(message)
47}
48
49func (u *ConcurrentUi) Warn(message string) {
50 u.l.Lock()
51 defer u.l.Unlock()
52
53 u.Ui.Warn(message)
54}