github.com/asifdxtreme/cli@v6.1.3-0.20150123051144-9ead8700b4ae+incompatible/fixtures/plugins/test_2.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 Test2 struct{} 17 18 func (c *Test2) Run(cliConnection plugin.CliConnection, args []string) { 19 if args[0] == "test_2_cmd1" { 20 theFirstCmd() 21 } else if args[0] == "test_2_cmd2" { 22 theSecondCmd() 23 } 24 } 25 26 func (c *Test2) GetMetadata() plugin.PluginMetadata { 27 return plugin.PluginMetadata{ 28 Name: "Test2", 29 Commands: []plugin.Command{ 30 { 31 Name: "test_2_cmd1", 32 HelpText: "help text for test_2_cmd1", 33 }, 34 { 35 Name: "test_2_cmd2", 36 HelpText: "help text for test_2_cmd2", 37 }, 38 }, 39 } 40 } 41 42 func theFirstCmd() { 43 fmt.Println("You called cmd1 in test_2") 44 } 45 46 func theSecondCmd() { 47 fmt.Println("You called cmd2 in test_2") 48 } 49 50 func main() { 51 plugin.Start(new(Test2)) 52 }