// sendCommand sends a command to the Tor server and returns its response, as a
// single space-delimited string, and code.
434846
func (c *Controller) sendCommand(command string) (int, string, error) {
	if err := c.conn.Writer.PrintfLine(command); err != nil {
		return 0, "", err
	}

	// We'll use ReadResponse as it has built-in support for multi-line
	// text protocol responses.
	code, reply, err := c.conn.Reader.ReadResponse(success)
	if err != nil {
		return code, reply, err
	}

	return code, reply, nil
}
804712
func ParseCommand(line string) *Command {
	words := strings.Split(line, " ")
	command := strings.ToUpper(words[0])
	args := strings.Join(words[1:len(words)], " ")

	return &Command{
		verb: command,
		args: args,
		orig: line,
	}
}
823378
func (s *ContainerProperties) SetCommand(v []*string) *ContainerProperties {
	s.Command = v
	return s
}
148156
func (mc MongoClient) UpdateCommand(c contract.Command) error {
	var mapped models.Command
	id, err := mapped.FromContract(c)
	if err != nil {
		return errors.New("FromContract failed")
	}

	mapped.TimestampForUpdate()

	return mc.updateId(db.Command, id, mapped)
}
771470
func panicCommand(format string, values ...interface{}) {
	e := commandError{fmt.Errorf(format, values...)}
	panic(e)
}
962312
func (s *ContainerOverride) SetCommand(v []*string) *ContainerOverride {
	s.Command = v
	return s
}
1244173
func (c *connToLeader) forwardCommand(cb *commandCallback, cmdName string, args [][]byte) error {
	c.l.Lock()
	defer c.l.Unlock()
	// marshal log object
	lg := logForCommand(cb.originAddr, cb.reqNo, cmdName, args)
	// put response chan in pending
	// send
	err := c.e.Encode(lg)
	if err != nil {
		cb.cancel()
		cb.result <- Result{nil, err}
		return err
	} else {
		// so our responseReader will forward appropriately
		c.pending <- cb
	}
	return nil
}
1027492
func (c *Client) sendRequest(jReq *jsonRequest) {
	// Choose which marshal and send function to use depending on whether
	// the client running in HTTP POST mode or not.  When running in HTTP
	// POST mode, the command is issued via an HTTP client.  Otherwise,
	// the command is issued via the asynchronous websocket channels.
	if c.config.HTTPPostMode {
		c.sendPost(jReq)
		return
	}

	// Check whether the websocket connection has never been established,
	// in which case the handler goroutines are not running.
	select {
	case <-c.connEstablished:
	default:
		jReq.responseChan <- &response{err: ErrClientNotConnected}
		return
	}

	// Add the request to the internal tracking map so the response from the
	// remote server can be properly detected and routed to the response
	// channel.  Then send the marshalled request via the websocket
	// connection.
	if err := c.addRequest(jReq); err != nil {
		jReq.responseChan <- &response{err: err}
		return
	}
	log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
	c.sendMessage(jReq.marshalledJSON)
}
633777
func (s *SendCommandOutput) SetCommand(v *Command) *SendCommandOutput {
	s.Command = v
	return s
}
1352765
func runCommand(cmd *exec.Cmd) (stdout string, stderr string, exitCode int, err error) {
	var stderrBuffer bytes.Buffer
	var stdoutBuffer bytes.Buffer
	cmd.Stderr = &stderrBuffer
	cmd.Stdout = &stdoutBuffer
	cmdErr := cmd.Run()
	exitCode, success := utils.GetExitStatus(cmdErr)
	if success {
		cmdErr = nil
	}
	return stdoutBuffer.String(), stderrBuffer.String(), exitCode, cmdErr
}
928908
func (s *HealthCheck) SetCommand(v []*string) *HealthCheck {
	s.Command = v
	return s
}
1344943
func (f *Flaeg) AddCommand(command *Command) {
	f.commands = append(f.commands, command)
}
634002
func (a *API) executeCommand(f func(map[string]interface{}) interface{},
	res http.ResponseWriter,
	req *http.Request,
) {

	body := make(map[string]interface{})
	json.NewDecoder(req.Body).Decode(&body)

	if f != nil {
		a.writeJSON(map[string]interface{}{"result": f(body)}, res)
	} else {
		a.writeJSON(map[string]interface{}{"error": "Unknown Command"}, res)
	}
}
202811
func (c *client) doCommand(command string, payload map[string]string) (response []byte, err error) {
	if payload == nil {
		payload = make(map[string]string)
	}

	payload["command"] = command
	payload["nonce"] = strconv.FormatInt(time.Now().UnixNano(), 10)

	return c.do("POST", "tradingApi", payload, true)
}
937540
func (r *Redis) ExecuteCommand(args ...interface{}) (*Reply, error) {
	c, err := r.pool.Get()
	if err != nil {
		return nil, err
	}
	if err := c.SendCommand(args...); err != nil {
		if err != io.EOF {
			return nil, err
		}
		c, err = r.pool.Get()
		if err != nil {
			return nil, err
		}
		if err = c.SendCommand(args...); err != nil {
			return nil, err
		}
	}
	rp, err := c.RecvReply()
	if err != nil {
		if err != io.EOF {
			return nil, err
		}
		c, err = r.pool.Get()
		if err != nil {
			return nil, err
		}
		if err = c.SendCommand(args...); err != nil {
			return nil, err
		}
		rp, err = c.RecvReply()
	}
	if err == nil {
		r.pool.Put(c)
	}
	return rp, err
}
698888
func MustCommand(v interface{}) *exec.Cmd {
	if command, err := Command(v); err == nil {
		return command
	} else {
		panic(err.Error())
	}
}
956796
func (s *JobUpdate) SetCommand(v *JobCommand) *JobUpdate {
	s.Command = v
	return s
}