]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/mitchellh/cli/command_mock.go
Merge branch 'fix_read_test' of github.com:alexandreFre/terraform-provider-statuscake
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / mitchellh / cli / command_mock.go
CommitLineData
15c0b25d
AP
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}