github.com/jasonkeene/cli@v6.14.1-0.20160816203908-ca5715166dfb+incompatible/fixtures/plugins/test_with_push_short_name.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  	"github.com/cloudfoundry/cli/plugin"
    14  )
    15  
    16  type TestWithPushShortName struct {
    17  }
    18  
    19  func (c *TestWithPushShortName) Run(cliConnection plugin.CliConnection, args []string) {
    20  	if args[0] == "p" {
    21  		thePushCmd()
    22  	}
    23  }
    24  
    25  func (c *TestWithPushShortName) GetMetadata() plugin.PluginMetadata {
    26  	return plugin.PluginMetadata{
    27  		Name: "TestWithPushShortName",
    28  		Commands: []plugin.Command{
    29  			{
    30  				Name:     "p",
    31  				HelpText: "plugin short name p",
    32  			},
    33  		},
    34  	}
    35  }
    36  
    37  func thePushCmd() {
    38  	fmt.Println("You called p within the plugin")
    39  }
    40  
    41  func main() {
    42  	plugin.Start(new(TestWithPushShortName))
    43  }