aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/mitchellh/cli/command_mock.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mitchellh/cli/command_mock.go')
-rw-r--r--vendor/github.com/mitchellh/cli/command_mock.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/cli/command_mock.go b/vendor/github.com/mitchellh/cli/command_mock.go
new file mode 100644
index 0000000..7a584b7
--- /dev/null
+++ b/vendor/github.com/mitchellh/cli/command_mock.go
@@ -0,0 +1,63 @@
1package cli
2
3import (
4 "github.com/posener/complete"
5)
6
7// MockCommand is an implementation of Command that can be used for tests.
8// It is publicly exported from this package in case you want to use it
9// externally.
10type MockCommand struct {
11 // Settable
12 HelpText string
13 RunResult int
14 SynopsisText string
15
16 // Set by the command
17 RunCalled bool
18 RunArgs []string
19}
20
21func (c *MockCommand) Help() string {
22 return c.HelpText
23}
24
25func (c *MockCommand) Run(args []string) int {
26 c.RunCalled = true
27 c.RunArgs = args
28
29 return c.RunResult
30}
31
32func (c *MockCommand) Synopsis() string {
33 return c.SynopsisText
34}
35
36// MockCommandAutocomplete is an implementation of CommandAutocomplete.
37type MockCommandAutocomplete struct {
38 MockCommand
39
40 // Settable
41 AutocompleteArgsValue complete.Predictor
42 AutocompleteFlagsValue complete.Flags
43}
44
45func (c *MockCommandAutocomplete) AutocompleteArgs() complete.Predictor {
46 return c.AutocompleteArgsValue
47}
48
49func (c *MockCommandAutocomplete) AutocompleteFlags() complete.Flags {
50 return c.AutocompleteFlagsValue
51}
52
53// MockCommandHelpTemplate is an implementation of CommandHelpTemplate.
54type MockCommandHelpTemplate struct {
55 MockCommand
56
57 // Settable
58 HelpTemplateText string
59}
60
61func (c *MockCommandHelpTemplate) HelpTemplate() string {
62 return c.HelpTemplateText
63}