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