File: autocomplete.go

package info (click to toggle)
golang-github-mitchellh-cli 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 280 kB
  • sloc: makefile: 16
file content (43 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cli

import (
	"github.com/posener/complete/cmd/install"
)

// autocompleteInstaller is an interface to be implemented to perform the
// autocomplete installation and uninstallation with a CLI.
//
// This interface is not exported because it only exists for unit tests
// to be able to test that the installation is called properly.
type autocompleteInstaller interface {
	Install(string) error
	Uninstall(string) error
}

// realAutocompleteInstaller uses the real install package to do the
// install/uninstall.
type realAutocompleteInstaller struct{}

func (i *realAutocompleteInstaller) Install(cmd string) error {
	return install.Install(cmd)
}

func (i *realAutocompleteInstaller) Uninstall(cmd string) error {
	return install.Uninstall(cmd)
}

// mockAutocompleteInstaller is used for tests to record the install/uninstall.
type mockAutocompleteInstaller struct {
	InstallCalled   bool
	UninstallCalled bool
}

func (i *mockAutocompleteInstaller) Install(cmd string) error {
	i.InstallCalled = true
	return nil
}

func (i *mockAutocompleteInstaller) Uninstall(cmd string) error {
	i.UninstallCalled = true
	return nil
}