| 23 | } |
| 24 | |
| 25 | func (pluginDemo *PluginDemonstratingParams) Run(cliConnection plugin.CliConnection, args []string) { |
| 26 | // Initialize flags |
| 27 | echoFlagSet := flag.NewFlagSet("echo", flag.ExitOnError) |
| 28 | uppercase := echoFlagSet.Bool("uppercase", false, "displayed all provided text in uppercase") |
| 29 | |
| 30 | // Parse starting from [1] because the [0]th element is the |
| 31 | // name of the command |
| 32 | err := echoFlagSet.Parse(args[1:]) |
| 33 | if err != nil { |
| 34 | fmt.Println(err) |
| 35 | os.Exit(1) |
| 36 | } |
| 37 | |
| 38 | var itemToEcho string |
| 39 | for _, value := range echoFlagSet.Args() { |
| 40 | if *uppercase { |
| 41 | itemToEcho += strings.ToUpper(value) + " " |
| 42 | } else { |
| 43 | itemToEcho += value + " " |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | fmt.Println(itemToEcho) |
| 48 | } |
| 49 | |
| 50 | func (pluginDemo *PluginDemonstratingParams) GetMetadata() plugin.PluginMetadata { |
| 51 | return plugin.PluginMetadata{ |