//
// This method executes one command
//
19856
func (cmd *Cmd) oneCmd(line string) (stop bool) {
	if cmd.GetBoolVar("timing") {
		start := time.Now()
		defer func() {
			d := time.Since(start).Truncate(time.Millisecond)
			cmd.SetVar("elapsed", d.Seconds())

			if !cmd.SilentResult() {
				fmt.Println("Elapsed:", d)
			}
		}()
	}

	if cmd.GetBoolVar("echo") {
		fmt.Println(cmd.Prompt, line)
	}

	if cmd.EnableShell && strings.HasPrefix(line, "!") {
		shellExec(line[1:])
		return
	}

	var cname, params string

	parts := strings.SplitN(line, " ", 2)

	cname = parts[0]
	if len(parts) > 1 {
		params = strings.TrimSpace(parts[1])
	}

	if command, ok := cmd.Commands[cname]; ok {
		stop = command.Call(params)
	} else {
		cmd.Default(line)
	}

	return
}
1315406
func (c *CLI) Subcommand() string {
	c.once.Do(c.init)
	return c.subcommand
}
226621
func (lp *lookupPeer) Command(cmd *nsq.Command) ([]byte, error) {
	initialState := lp.state
	if lp.state != stateConnected {
		err := lp.Connect()
		if err != nil {
			return nil, err
		}
		lp.state = stateConnected
		_, err = lp.Write(nsq.MagicV1)
		if err != nil {
			lp.Close()
			return nil, err
		}
		if initialState == stateDisconnected {
			lp.connectCallback(lp)
		}
		if lp.state != stateConnected {
			return nil, fmt.Errorf("lookupPeer connectCallback() failed")
		}
	}
	if cmd == nil {
		return nil, nil
	}
	_, err := cmd.WriteTo(lp)
	if err != nil {
		lp.Close()
		return nil, err
	}
	resp, err := readResponseBounded(lp, lp.maxBodySize)
	if err != nil {
		lp.Close()
		return nil, err
	}
	return resp, nil
}
1104706
func Subcommand() (o string) {
	if len(os.Args) >= 2 && os.Args[1][0] != '-' {
		o = os.Args[1]
		os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
	}
	return
}
1009367
func Command(args ...string) *exec.Cmd {
	return &exec.Cmd{
		Path: Self(),
		Args: args,
	}
}
799175
func (c *Client) ExecuteCommand(cmd string) (string, error) {
	err := c.VerifyClient()
	if err != nil {
		return "", err
	}

	// Don't allocate something we may not need, e.g. if we can't build a client
	var b bytes.Buffer

	// Each ClientConn can support multiple interactive sessions,
	// represented by a Session.
	s, err := c.client.NewSession()
	if err != nil {
		return "", err
	}

	// Once a Session is created, you can execute a single command on
	// the remote side using the Run method.
	s.Stdout = &b

	err = s.Run(cmd)
	if err != nil {
		return "", err
	}

	return b.String(), nil
}
428172
func (cli *SeesawCLI) Execute(cmdline string) error {
	cmd, subcmds, _, args := FindCommand(cmdline)
	if cmd != nil {
		return cmd.function(cli, args)
	}
	if subcmds != nil {
		return errors.New("Incomplete command.")
	}
	return errors.New("Unknown command.")
}
1350436
func Execute() {
	if err := RootCmd.Execute(); err != nil {
		exitCode := 1
		if stat, ok := status.FromError(err); ok {
			exitCode = int(stat.Code())
			fmt.Fprintln(os.Stderr, stat.Message())
		} else {
			fmt.Fprintf(os.Stderr, "%v\n", err)
		}
		fmt.Fprintf(os.Stderr, "\nPlease use -h,--help for more information\n")
		os.Exit(exitCode)
	}
}
1100445
func Execute() {
	if err := FusisCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}
426916
func (s *server) Command(cmd string, args [][]byte) <-chan Result {

	if s.IsLeader() {
		cb := s.state.newCommand()
		cmdBytes := bytesForCommand(cb.originAddr, cb.reqNo, cmd, args)
		s.raft.Apply(cmdBytes, commandTimeout)
		return cb.result
	}
	// couldn't exec as leader, fallback to forwarding
	cb, err := s.dispatchToLeader(cmd, args)
	if err != nil {
		if cb != nil {
			cb.cancel()
		}
		ret := make(chan Result, 1)
		ret <- Result{nil, err}
		return ret
	}
	return cb.result
}
477633
func (c *Cluster) Execute(cmd *Command) (*Reply, error) {
	if len(cmd.args) < 1 {
		return nil, ErrNoKey
	}
	key := string(convertString(cmd.args[0]))
	pool := c.shards[DefaultShardStrategy(key, len(c.shards))]
	conn, err := pool.Acquire()
	if err != nil {
		return nil, err
	}
	if conn == nil {
		return nil, ErrNotConnected
	}
	defer pool.Release(conn)
	return cmd.Run(conn)
}
644835
func commandUsage(method string) {
	usage, err := btcjson.MethodUsageText(method)
	if err != nil {
		// This should never happen since the method was already checked
		// before calling this function, but be safe.
		fmt.Fprintln(os.Stderr, "Failed to obtain command usage:", err)
		return
	}

	fmt.Fprintln(os.Stderr, "Usage:")
	fmt.Fprintf(os.Stderr, "  %s\n", usage)
}
60957
func main() {
	app := cli.NewApp()
	app.Name = Name
	app.Version = Version
	app.Author = "kyokomi"
	app.Email = ""
	app.Usage = ""

	app.Flags = GlobalFlags
	app.Commands = Commands
	app.CommandNotFound = CommandNotFound

	app.Run(os.Args)
}
1070362
func (cmd *PunchCmd) Execute(args []string) bool {
	if len(args) > 0 {

		var combo string

		flagSet := flag.NewFlagSet("", flag.ContinueOnError)
		flagSet.Usage = func() {
			fmt.Println(cmd.LongHelp())
		}

		// don't use flag description since we're setting Usage
		flagSet.StringVar(&combo, "combo", "", "")

		// Parse will succeed or os.Exit
		flagSet.Parse(args)

		fmt.Println("You executed punch combo " + combo)

		return true
	}
	return false
}
318792
func (cli *CLI) Command(name, help string, onCommand CLICommand) *kingpin.CmdClause {
	cmd := cli.app.Command(name, help)
	cli.dispatchers[name] = onCommand
	return cmd
}
31115
func (f *Factory) Command() string {
	if len(os.Args) == 0 {
		return ""
	}
	base := filepath.Base(os.Args[0])
	args := append([]string{base}, os.Args[1:]...)
	return strings.Join(args, " ")
}
730938
func (c *Cluster) Execute(command Command) error {
	if command == nil {
		return ErrClusterCommandRequired
	}
	async := &Async{
		Command: command,
	}
	c.execute(async)
	if async.Error != nil {
		return async.Error
	}
	if cerr := command.Error(); cerr != nil {
		return cerr
	}
	return nil
}