github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/plugin/rpc/fake_command/fake_command2.go (about) 1 package fake_command 2 3 import ( 4 "fmt" 5 6 "github.com/cloudfoundry/cli/cf/command_registry" 7 "github.com/cloudfoundry/cli/cf/requirements" 8 "github.com/cloudfoundry/cli/cf/terminal" 9 "github.com/cloudfoundry/cli/flags" 10 ) 11 12 type FakeCommand2 struct { 13 Data string 14 req fakeReq2 15 ui terminal.UI 16 } 17 18 func init() { 19 command_registry.Register(FakeCommand2{Data: "FakeCommand2 data", req: fakeReq2{}}) 20 } 21 22 func (cmd FakeCommand2) MetaData() command_registry.CommandMetadata { 23 return command_registry.CommandMetadata{ 24 Name: "fake-non-codegangsta-command2", 25 Description: "Description for fake-command2 with bad requirement", 26 Usage: "Usage of fake-command", 27 } 28 } 29 30 func (cmd FakeCommand2) Requirements(_ requirements.Factory, _ flags.FlagContext) (reqs []requirements.Requirement, err error) { 31 return []requirements.Requirement{cmd.req}, nil 32 } 33 34 func (cmd FakeCommand2) SetDependency(deps command_registry.Dependency, pluginCall bool) command_registry.Command { 35 cmd.req.ui = deps.Ui 36 cmd.ui = deps.Ui 37 cmd.ui.Say("SetDependency() called, pluginCall " + fmt.Sprintf("%t", pluginCall)) 38 39 return cmd 40 } 41 42 func (cmd FakeCommand2) Execute(c flags.FlagContext) { 43 cmd.ui.Say("Command Executed") 44 } 45 46 type fakeReq2 struct { 47 ui terminal.UI 48 } 49 50 func (f fakeReq2) Execute() bool { 51 f.ui.Say("Requirement executed and failed") 52 return false 53 }