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