diff options
Diffstat (limited to 'vendor/github.com/mitchellh/cli/ui_concurrent.go')
-rw-r--r-- | vendor/github.com/mitchellh/cli/ui_concurrent.go | 54 |
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 @@ | |||
1 | package cli | ||
2 | |||
3 | import ( | ||
4 | "sync" | ||
5 | ) | ||
6 | |||
7 | // ConcurrentUi is a wrapper around a Ui interface (and implements that | ||
8 | // interface) making the underlying Ui concurrency safe. | ||
9 | type ConcurrentUi struct { | ||
10 | Ui Ui | ||
11 | l sync.Mutex | ||
12 | } | ||
13 | |||
14 | func (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 | |||
21 | func (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 | |||
28 | func (u *ConcurrentUi) Error(message string) { | ||
29 | u.l.Lock() | ||
30 | defer u.l.Unlock() | ||
31 | |||
32 | u.Ui.Error(message) | ||
33 | } | ||
34 | |||
35 | func (u *ConcurrentUi) Info(message string) { | ||
36 | u.l.Lock() | ||
37 | defer u.l.Unlock() | ||
38 | |||
39 | u.Ui.Info(message) | ||
40 | } | ||
41 | |||
42 | func (u *ConcurrentUi) Output(message string) { | ||
43 | u.l.Lock() | ||
44 | defer u.l.Unlock() | ||
45 | |||
46 | u.Ui.Output(message) | ||
47 | } | ||
48 | |||
49 | func (u *ConcurrentUi) Warn(message string) { | ||
50 | u.l.Lock() | ||
51 | defer u.l.Unlock() | ||
52 | |||
53 | u.Ui.Warn(message) | ||
54 | } | ||