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

Method callCliCommand

plugin/cli_connection.go:76–110  ·  view source on GitHub ↗
(silently bool, args ...string)

Source from the content-addressed store, hash-verified

74}
75
76func (c *cliConnection) callCliCommand(silently bool, args ...string) ([]string, error) {
77 var (
78 success bool
79 cmdOutput []string
80 callCoreCommandErr error
81 getOutputAndResetErr error
82 disableTerminalOutputErr error
83 )
84
85 _ = c.withClientDo(func(client *rpc.Client) error {
86 disableTerminalOutputErr = client.Call("CliRpcCmd.DisableTerminalOutput", silently, &success)
87 callCoreCommandErr = client.Call("CliRpcCmd.CallCoreCommand", args, &success)
88 getOutputAndResetErr = client.Call("CliRpcCmd.GetOutputAndReset", success, &cmdOutput)
89
90 return nil
91 })
92
93 if disableTerminalOutputErr != nil {
94 return []string{}, disableTerminalOutputErr
95 }
96
97 if callCoreCommandErr != nil {
98 return []string{}, callCoreCommandErr
99 }
100
101 if !success {
102 return []string{}, errors.New("Error executing cli core command")
103 }
104
105 if getOutputAndResetErr != nil {
106 return []string{}, errors.New("something completely unexpected happened")
107 }
108
109 return cmdOutput, nil
110}
111
112func (c *cliConnection) pingCLI() {
113 // call back to cf saying we have been setup

Callers 2

CliCommandMethod · 0.95

Calls 1

withClientDoMethod · 0.95

Tested by

no test coverage detected