-
Notifications
You must be signed in to change notification settings - Fork 929
/
fake_command2.go
58 lines (47 loc) · 1.36 KB
/
fake_command2.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package fakecommand
import (
"errors"
"fmt"
"code.cloudfoundry.org/cli/cf/commandregistry"
"code.cloudfoundry.org/cli/cf/flags"
"code.cloudfoundry.org/cli/cf/requirements"
"code.cloudfoundry.org/cli/cf/terminal"
)
type FakeCommand2 struct {
Data string
req fakeReq2
ui terminal.UI
}
func init() {
commandregistry.Register(FakeCommand2{Data: "FakeCommand2 data", req: fakeReq2{}})
}
func (cmd FakeCommand2) MetaData() commandregistry.CommandMetadata {
return commandregistry.CommandMetadata{
Name: "fake-command2",
Description: "Description for fake-command2 with bad requirement",
Usage: []string{
"Usage of fake-command",
},
}
}
func (cmd FakeCommand2) Requirements(_ requirements.Factory, _ flags.FlagContext) ([]requirements.Requirement, error) {
reqs := []requirements.Requirement{cmd.req}
return reqs, nil
}
func (cmd FakeCommand2) SetDependency(deps commandregistry.Dependency, pluginCall bool) commandregistry.Command {
cmd.req.ui = deps.UI
cmd.ui = deps.UI
cmd.ui.Say("SetDependency() called, pluginCall " + fmt.Sprintf("%t", pluginCall))
return cmd
}
func (cmd FakeCommand2) Execute(c flags.FlagContext) error {
cmd.ui.Say("Command Executed")
return nil
}
type fakeReq2 struct {
ui terminal.UI
}
func (f fakeReq2) Execute() error {
f.ui.Say("Requirement executed and failed")
return errors.New("Requirement executed and failed")
}