github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/plugin/rpc/fake_command/fake_command1.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 FakeCommand1 struct {
    13  	Data string
    14  	req  fakeReq
    15  	ui   terminal.UI
    16  }
    17  
    18  func init() {
    19  	command_registry.Register(FakeCommand1{Data: "FakeCommand1 data", req: fakeReq{ui: nil}})
    20  }
    21  
    22  func (cmd FakeCommand1) MetaData() command_registry.CommandMetadata {
    23  	return command_registry.CommandMetadata{
    24  		Name:        "fake-non-codegangsta-command",
    25  		Description: "Description for fake-command",
    26  		Usage:       "Usage of fake-command",
    27  	}
    28  }
    29  
    30  func (cmd FakeCommand1) Requirements(_ requirements.Factory, _ flags.FlagContext) (reqs []requirements.Requirement, err error) {
    31  	return []requirements.Requirement{cmd.req}, nil
    32  }
    33  
    34  func (cmd FakeCommand1) SetDependency(deps command_registry.Dependency, pluginCall bool) command_registry.Command {
    35  	if cmd.ui != nil {
    36  		cmd.ui.Say("SetDependency() called, pluginCall " + fmt.Sprintf("%t", pluginCall))
    37  	}
    38  
    39  	cmd.req.ui = deps.Ui
    40  	cmd.ui = deps.Ui
    41  
    42  	return cmd
    43  }
    44  
    45  func (cmd FakeCommand1) Execute(c flags.FlagContext) {
    46  	cmd.ui.Say("Command Executed")
    47  }
    48  
    49  type fakeReq struct {
    50  	ui terminal.UI
    51  }
    52  
    53  func (f fakeReq) Execute() bool {
    54  	f.ui.Say("Requirement executed")
    55  	return true
    56  }