aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/mitchellh/cli/autocomplete.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mitchellh/cli/autocomplete.go')
-rw-r--r--vendor/github.com/mitchellh/cli/autocomplete.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/cli/autocomplete.go b/vendor/github.com/mitchellh/cli/autocomplete.go
new file mode 100644
index 0000000..3bec625
--- /dev/null
+++ b/vendor/github.com/mitchellh/cli/autocomplete.go
@@ -0,0 +1,43 @@
1package cli
2
3import (
4 "github.com/posener/complete/cmd/install"
5)
6
7// autocompleteInstaller is an interface to be implemented to perform the
8// autocomplete installation and uninstallation with a CLI.
9//
10// This interface is not exported because it only exists for unit tests
11// to be able to test that the installation is called properly.
12type autocompleteInstaller interface {
13 Install(string) error
14 Uninstall(string) error
15}
16
17// realAutocompleteInstaller uses the real install package to do the
18// install/uninstall.
19type realAutocompleteInstaller struct{}
20
21func (i *realAutocompleteInstaller) Install(cmd string) error {
22 return install.Install(cmd)
23}
24
25func (i *realAutocompleteInstaller) Uninstall(cmd string) error {
26 return install.Uninstall(cmd)
27}
28
29// mockAutocompleteInstaller is used for tests to record the install/uninstall.
30type mockAutocompleteInstaller struct {
31 InstallCalled bool
32 UninstallCalled bool
33}
34
35func (i *mockAutocompleteInstaller) Install(cmd string) error {
36 i.InstallCalled = true
37 return nil
38}
39
40func (i *mockAutocompleteInstaller) Uninstall(cmd string) error {
41 i.UninstallCalled = true
42 return nil
43}