github.com/Thanhphan1147/cloudfoundry-cli@v7.1.0+incompatible/fixtures/plugins/test_with_push.go (about)

     1  /**
     2  	* 1. Setup the server so cf can call it under main.
     3  				e.g. `cf my-plugin` creates the callable server. now we can call the Run command
     4  	* 2. Implement Run that is the actual code of the plugin!
     5  	* 3. Return an error
     6  **/
     7  
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  
    13  	"code.cloudfoundry.org/cli/plugin"
    14  )
    15  
    16  type TestWithPush struct {
    17  }
    18  
    19  func (c *TestWithPush) Run(cliConnection plugin.CliConnection, args []string) {
    20  	if args[0] == "push" {
    21  		thePushCmd()
    22  	}
    23  }
    24  
    25  func (c *TestWithPush) GetMetadata() plugin.PluginMetadata {
    26  	return plugin.PluginMetadata{
    27  		Name: "TestWithPush",
    28  		Commands: []plugin.Command{
    29  			{
    30  				Name:     "push",
    31  				HelpText: "push text for test_with_push",
    32  			},
    33  		},
    34  	}
    35  }
    36  
    37  func thePushCmd() {
    38  	fmt.Println("You called push in test_with_push")
    39  }
    40  
    41  func main() {
    42  	plugin.Start(new(TestWithPush))
    43  }