-
Notifications
You must be signed in to change notification settings - Fork 15
/
fake_command2.go
53 lines (42 loc) · 1.31 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
package fake_command
import (
"fmt"
"github.com/cloudfoundry/cli/cf/command_registry"
"github.com/cloudfoundry/cli/cf/requirements"
"github.com/cloudfoundry/cli/cf/terminal"
"github.com/cloudfoundry/cli/flags"
)
type FakeCommand2 struct {
Data string
req fakeReq2
ui terminal.UI
}
func init() {
command_registry.Register(FakeCommand2{Data: "FakeCommand2 data", req: fakeReq2{}})
}
func (cmd FakeCommand2) MetaData() command_registry.CommandMetadata {
return command_registry.CommandMetadata{
Name: "fake-non-codegangsta-command2",
Description: "Description for fake-command2 with bad requirement",
Usage: "Usage of fake-command",
}
}
func (cmd FakeCommand2) Requirements(_ requirements.Factory, _ flags.FlagContext) (reqs []requirements.Requirement, err error) {
return []requirements.Requirement{cmd.req}, nil
}
func (cmd FakeCommand2) SetDependency(deps command_registry.Dependency, pluginCall bool) command_registry.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) {
cmd.ui.Say("Command Executed")
}
type fakeReq2 struct {
ui terminal.UI
}
func (f fakeReq2) Execute() bool {
f.ui.Say("Requirement executed and failed")
return false
}