MCPcopy
hub / github.com/cloudfoundry/cli / Run

Method Run

plugin/plugin_examples/echo/echo.go:25–48  ·  view source on GitHub ↗
(cliConnection plugin.CliConnection, args []string)

Source from the content-addressed store, hash-verified

23}
24
25func (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
50func (pluginDemo *PluginDemonstratingParams) GetMetadata() plugin.PluginMetadata {
51 return plugin.PluginMetadata{

Callers

nothing calls this directly

Calls 5

BoolMethod · 0.65
ParseMethod · 0.65
PrintlnMethod · 0.65
ExitMethod · 0.65
ArgsMethod · 0.65

Tested by

no test coverage detected