github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/fixtures/plugins/test_with_orgs_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  	"code.cloudfoundry.org/cli/plugin"
    14  )
    15  
    16  type TestWithOrgsShortName struct {
    17  }
    18  
    19  func (c *TestWithOrgsShortName) Run(cliConnection plugin.CliConnection, args []string) {
    20  	if args[0] == "o" {
    21  		theOrgsCmd()
    22  	}
    23  }
    24  
    25  func (c *TestWithOrgsShortName) GetMetadata() plugin.PluginMetadata {
    26  	return plugin.PluginMetadata{
    27  		Name: "TestWithOrgsShortName",
    28  		Commands: []plugin.Command{
    29  			{
    30  				Name:     "o",
    31  				HelpText: "",
    32  			},
    33  		},
    34  	}
    35  }
    36  
    37  func theOrgsCmd() {
    38  	fmt.Println("You called o in test_with_orgs_short_name")
    39  }
    40  
    41  func main() {
    42  	plugin.Start(new(TestWithOrgsShortName))
    43  }