github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/fixtures/plugins/panics.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 "os" 12 13 "code.cloudfoundry.org/cli/plugin" 14 ) 15 16 type Panics struct { 17 } 18 19 func (c *Panics) Run(cliConnection plugin.CliConnection, args []string) { 20 if args[0] == "panic" { 21 panic("OMG") 22 } else if args[0] == "exit1" { 23 os.Exit(1) 24 } 25 } 26 27 func (c *Panics) GetMetadata() plugin.PluginMetadata { 28 return plugin.PluginMetadata{ 29 Name: "Panics", 30 Commands: []plugin.Command{ 31 { 32 Name: "panic", 33 HelpText: "omg panic", 34 }, 35 { 36 Name: "exit1", 37 HelpText: "omg exit1", 38 }, 39 }, 40 } 41 } 42 43 func main() { 44 plugin.Start(new(Panics)) 45 }