github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/fixtures/plugins/panics.go (about)

     1  // +build !V7
     2  
     3  /**
     4  	* 1. Setup the server so cf can call it under main.
     5  				e.g. `cf my-plugin` creates the callable server. now we can call the Run command
     6  	* 2. Implement Run that is the actual code of the plugin!
     7  	* 3. Return an error
     8  **/
     9  
    10  package main
    11  
    12  import (
    13  	"os"
    14  
    15  	"code.cloudfoundry.org/cli/plugin"
    16  )
    17  
    18  type Panics struct {
    19  }
    20  
    21  func (c *Panics) Run(cliConnection plugin.CliConnection, args []string) {
    22  	if args[0] == "panic" {
    23  		panic("OMG")
    24  	} else if args[0] == "exit1" {
    25  		os.Exit(1)
    26  	}
    27  }
    28  
    29  func (c *Panics) GetMetadata() plugin.PluginMetadata {
    30  	return plugin.PluginMetadata{
    31  		Name: "Panics",
    32  		Commands: []plugin.Command{
    33  			{
    34  				Name:     "panic",
    35  				HelpText: "omg panic",
    36  			},
    37  			{
    38  				Name:     "exit1",
    39  				HelpText: "omg exit1",
    40  			},
    41  		},
    42  	}
    43  }
    44  
    45  func main() {
    46  	plugin.Start(new(Panics))
    47  }