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

Function Start

plugin/plugin_shim.go:15–36  ·  view source on GitHub ↗

** * This function is called by the plugin to setup their server. This allows us to call Run on the plugin * os.Args[1] port CF_CLI rpc server is running on * os.Args[2] **OPTIONAL** * SendMetadata - used to fetch the plugin metadata **/

(cmd Plugin)

Source from the content-addressed store, hash-verified

13 * SendMetadata - used to fetch the plugin metadata
14**/
15func Start(cmd Plugin) {
16 if len(os.Args) < 2 {
17 fmt.Printf("This cf CLI plugin is not intended to be run on its own\n\n")
18 os.Exit(1)
19 }
20
21 cliConnection := NewCliConnection(os.Args[1])
22 cliConnection.pingCLI()
23 if isMetadataRequest(os.Args) {
24 cliConnection.sendPluginMetadataToCliServer(cmd.GetMetadata())
25 } else {
26 if version := MinCliVersionStr(cmd.GetMetadata().MinCliVersion); version != "" {
27 ok := cliConnection.isMinCliVersion(version)
28 if !ok {
29 fmt.Printf("Minimum CLI version %s is required to run this plugin command\n\n", version)
30 os.Exit(0)
31 }
32 }
33
34 cmd.Run(cliConnection, os.Args[2:])
35 }
36}
37
38func isMetadataRequest(args []string) bool {
39 return len(args) == 3 && args[2] == "SendMetadata"

Callers 15

mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls 10

NewCliConnectionFunction · 0.85
isMetadataRequestFunction · 0.85
MinCliVersionStrFunction · 0.85
pingCLIMethod · 0.80
isMinCliVersionMethod · 0.80
PrintfMethod · 0.65
ExitMethod · 0.65
GetMetadataMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected