]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/mitchellh/cli/autocomplete.go
Merge branch 'fix_read_test' of github.com:alexandreFre/terraform-provider-statuscake
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / mitchellh / cli / autocomplete.go
1 package cli
2
3 import (
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.
12 type 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.
19 type realAutocompleteInstaller struct{}
20
21 func (i *realAutocompleteInstaller) Install(cmd string) error {
22 return install.Install(cmd)
23 }
24
25 func (i *realAutocompleteInstaller) Uninstall(cmd string) error {
26 return install.Uninstall(cmd)
27 }
28
29 // mockAutocompleteInstaller is used for tests to record the install/uninstall.
30 type mockAutocompleteInstaller struct {
31 InstallCalled bool
32 UninstallCalled bool
33 }
34
35 func (i *mockAutocompleteInstaller) Install(cmd string) error {
36 i.InstallCalled = true
37 return nil
38 }
39
40 func (i *mockAutocompleteInstaller) Uninstall(cmd string) error {
41 i.UninstallCalled = true
42 return nil
43 }