]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - 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
CommitLineData
15c0b25d
AP
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}