// doCommand executes a client command which is processed through the raft pipeline.
5512
func (n *Node) doCommand(conn redcon.Conn, cmd redcon.Command) (interface{}, error) {
	if len(cmd.Args) == 0 {
		return nil, nil
	}
	var val interface{}
	var err error
	switch strings.ToLower(string(cmd.Args[0])) {
	default:
		val, err = n.handler.Command((*nodeApplier)(n), conn, cmd)
		if err == ErrDisabled {
			err = ErrUnknownCommand
		}
	case "raftaddpeer":
		val, err = n.doRaftAddPeer(conn, cmd)
	case "raftremovepeer":
		val, err = n.doRaftRemovePeer(conn, cmd)
	case "raftleader":
		val, err = n.doRaftLeader(conn, cmd)
	case "raftsnapshot":
		val, err = n.doRaftSnapshot(conn, cmd)
	case "raftshrinklog":
		val, err = n.doRaftShrinkLog(conn, cmd)
	case "raftstate":
		val, err = n.doRaftState(conn, cmd)
	case "raftstats":
		val, err = n.doRaftStats(conn, cmd)
	case "raftpeers":
		val, err = n.doRaftPeers(conn, cmd)
	case "quit":
		val, err = n.doQuit(conn, cmd)
	case "ping":
		val, err = n.doPing(conn, cmd)
	}
	if err != nil && conn != nil {
		// it's possible that this was a pipelined response.
		wr := redcon.BaseWriter(conn)
		if wr != nil {
			buf := wr.Buffer()
			rerrs := scanForErrors(buf)
			if len(rerrs) > 0 {
				wr.SetBuffer(nil)
				for _, rerr := range rerrs {
					conn.WriteError(n.translateError(errors.New(string(rerr)), string(cmd.Args[0])))
				}
			}
		}
		conn.WriteError(n.translateError(err, string(cmd.Args[0])))
	}
	return val, err
}
1218257
func (s *stream) readCommand() (dota.EDemoCommands, error) {
	c, err := s.readVarUint32()
	return dota.EDemoCommands(c), err
}
802296
func (b *Builder) handleCmd(args []string, heredoc string) error {
	log.Debugf("handling %s with args: %#v", commands.Cmd, args)

	b.config.Cmd = args

	return nil
}
1066983
func AddCommand(f Flag, sig os.Signal, handler SignalHandlerFunc) {
	if f != nil {
		AddFlag(f, sig)
	}
	if handler != nil {
		SetSigHandler(handler, sig)
	}
}
1186074
func (a *AppInstance) processCommand(url string, body string, method string) *CommandResponse {
	jsonMessage, err := json.Marshal(Command{URL: url, Method: method, Body: body})
	if err != nil {
		return &CommandResponse{}
	}

	a.commandChannel <- jsonMessage
	for {
		select {
		case r, r_ok := <-a.responseChannel:
			if r_ok {
				return r
			}
		case <-time.After(5 * time.Second):
			return &CommandResponse{}
		}
	}
}
915551
func initCommand(a Application, c *Command, r CommandRun, out io.Writer, helpUsed *bool) {
	r.GetFlags().Usage = getCommandUsageHandler(out, a, c, r, helpUsed)
	r.GetFlags().SetOutput(out)
	r.GetFlags().Init(c.Name(), flag.ContinueOnError)
}
849401
func (proto *Protocol) ProcessCommand(line string) (reply *Reply) {
	line = strings.Trim(line, "\r\n")
	proto.logf("Processing line: %s", line)

	words := strings.Split(line, " ")
	command := strings.ToUpper(words[0])
	args := strings.Join(words[1:len(words)], " ")
	proto.logf("In state %d, got command '%s', args '%s'", proto.State, command, args)

	cmd := ParseCommand(strings.TrimSuffix(line, "\r\n"))
	return proto.Command(cmd)
}
1052835
func (c *Command) AddCommand(cmds ...*Command) {
	for i, x := range cmds {
		if cmds[i] == c {
			panic("Command can't be a child of itself")
		}
		cmds[i].parent = c
		// update max lengths
		usageLen := len(x.Use)
		if usageLen > c.commandsMaxUseLen {
			c.commandsMaxUseLen = usageLen
		}
		commandPathLen := len(x.CommandPath())
		if commandPathLen > c.commandsMaxCommandPathLen {
			c.commandsMaxCommandPathLen = commandPathLen
		}
		nameLen := len(x.Name())
		if nameLen > c.commandsMaxNameLen {
			c.commandsMaxNameLen = nameLen
		}
		// If global normalization function exists, update all children
		if c.globNormFunc != nil {
			x.SetGlobalNormalizationFunc(c.globNormFunc)
		}
		c.commands = append(c.commands, x)
		c.commandsAreSorted = false
	}
}
733275
func (s *server) processCommand(command Command, e *ev) {
	s.debugln("server.command.process")

	// Create an entry for the command in the log.
	entry, err := s.log.createEntry(s.currentTerm, command, e)

	if err != nil {
		s.debugln("server.command.log.entry.error:", err)
		e.c <- err
		return
	}

	if err := s.log.appendEntry(entry); err != nil {
		s.debugln("server.command.log.error:", err)
		e.c <- err
		return
	}

	s.syncedPeer[s.Name()] = true
	if len(s.peers) == 0 {
		commitIndex := s.log.currentIndex()
		s.log.setCommitIndex(commitIndex)
		s.debugln("commit index ", commitIndex)
	}
}
210517
func ExecuteCommandFromArguments(arguments map[string]interface{}) error {

	p := NewRequestProcessor()

	c, err := p.ParseCommand(arguments)
	if err != nil {
		return err
	}

	return p.ExecuteRequest(c)
}
1119582
func addClientCommand() cli.Command {
	return cli.Command{
		Name:  "client",
		Usage: "starts the service in a client mode and attempts to acquire a bootstrap token",

		Flags: []cli.Flag{
			cli.StringFlag{
				Name:   "authorizer",
				Usage:  "provider we should use to authorize the node registration `NAME`",
				EnvVar: "AUTHORIZER",
				Value:  "aws",
			},
			cli.StringFlag{
				Name:   "node-url",
				Usage:  "the url for the node authorizer service `URL`",
				EnvVar: "NODE_AUTHORIZER_URL",
			},
			cli.StringFlag{
				Name:   "kubeapi-url",
				Usage:  "the url for the kubernetes api `URL`",
				EnvVar: "KUBEAPI_URL",
			},
			cli.StringFlag{
				Name:   "kubeconfig",
				Usage:  "location to write bootstrap token config `PATH`",
				EnvVar: "KUBECONFIG_BOOTSTRAP",
				Value:  "/var/lib/kubelet/bootstrap-kubeconfig",
			},
			cli.StringFlag{
				Name:   "tls-client-ca",
				Usage:  "file containing the certificate authority used to verify node endpoint `PATH`",
				EnvVar: "TLS_CLIENT_CA",
			},
			cli.StringFlag{
				Name:   "tls-cert",
				Usage:  "file containing the client certificate `PATH`",
				EnvVar: "TLS_CERT",
			},
			cli.StringFlag{
				Name:   "tls-private-key",
				Usage:  "file containing the client private key `PATH`",
				EnvVar: "TLS_PRIVATE_KEY",
			},
			cli.DurationFlag{
				Name:   "interval",
				Usage:  "an interval to wait between failed request `DURATION`",
				EnvVar: "INTERVAL",
				Value:  3 * time.Second,
			},
			cli.DurationFlag{
				Name:   "timeout",
				Usage:  "the max time to wait before timing out `DURATION`",
				EnvVar: "TIMEOUT",
				Value:  30 * time.Second,
			},
		},

		Action: func(ctx *cli.Context) error {
			return actionClientCommand(ctx)
		},
	}
}
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
}
1262014
func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eh.Command) error {
	err := eh.CheckCommand(cmd)
	if err != nil {
		return err
	}

	a, err := h.store.Load(ctx, h.t, cmd.AggregateID())
	if err != nil {
		return err
	} else if a == nil {
		return eh.ErrAggregateNotFound
	}

	if err = a.HandleCommand(ctx, cmd); err != nil {
		return err
	}

	return h.store.Save(ctx, a)
}
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)
}
998760
func (fw *Framework) PuppetAIOCmd(command string, def string) string {
	return PuppetAIOCmd(command, def)
}
332787
func gitCommand(dir string, args ...string) []byte {
	cmd := exec.Command("git", args...)
	cmd.Dir = dir
	out, err := cmd.Output()
	if err != nil {
		log.Error(2, fmt.Sprintf("Git: %v - %s", err, out))
	}
	return out
}
934983
func EventsCommand(factory app.ProjectFactory) cli.Command {
	return cli.Command{
		Name:   "events",
		Usage:  "Receive real time events from containers.",
		Action: app.WithProject(factory, app.ProjectEvents),
		Flags: []cli.Flag{
			cli.BoolFlag{
				Name:  "json",
				Usage: "Output events as a stream of json objects",
			},
		},
	}
}