// NewCommand returns a new instance of an argocd command
6589
func NewCommand() *cobra.Command {
	var (
		logLevel string
	)

	var command = &cobra.Command{
		Use:   cliName,
		Short: "argocd-util has internal tools used by Argo CD",
		Run: func(c *cobra.Command, args []string) {
			c.HelpFunc()(c, args)
		},
	}

	command.AddCommand(cli.NewVersionCmd(cliName))
	command.AddCommand(NewRunDexCommand())
	command.AddCommand(NewGenDexConfigCommand())
	command.AddCommand(NewImportCommand())
	command.AddCommand(NewExportCommand())
	command.AddCommand(NewClusterConfig())

	command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
	return command
}
1072918
func NewCopyCommand(dockerCli command.Cli) *cobra.Command {
	var opts copyOptions

	cmd := &cobra.Command{
		Use: `cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
	docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH`,
		Short: "Copy files/folders between a container and the local filesystem",
		Long: strings.Join([]string{
			"Copy files/folders between a container and the local filesystem\n",
			"\nUse '-' as the source to read a tar archive from stdin\n",
			"and extract it to a directory destination in a container.\n",
			"Use '-' as the destination to stream a tar archive of a\n",
			"container source to stdout.",
		}, ""),
		Args: cli.ExactArgs(2),
		RunE: func(cmd *cobra.Command, args []string) error {
			if args[0] == "" {
				return errors.New("source can not be empty")
			}
			if args[1] == "" {
				return errors.New("destination can not be empty")
			}
			opts.source = args[0]
			opts.destination = args[1]
			return runCopy(dockerCli, opts)
		},
	}

	flags := cmd.Flags()
	flags.BoolVarP(&opts.followLink, "follow-link", "L", false, "Always follow symbol link in SRC_PATH")
	flags.BoolVarP(&opts.copyUIDGID, "archive", "a", false, "Archive mode (copy all uid/gid information)")
	return cmd
}
921693
func New(dir, name string, args ...string) Command {
	c := Command{
		cmd: exec.Command(name, args...),
	}
	c.cmd.Dir = dir
	return c
}
1263414
func (o *NSGateway) CreateCommand(child *Command) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
815095
func (c *Cmd) Subcommand(subCommand ...*Cmd) *Cmd {
	c.Subcommands = append(c.Subcommands, subCommand...)
	return c
}
622048
func NewCommand() *Command {
	return &Command{
		Stderr:      os.Stderr,
		Stdout:      os.Stdout,
		Logger:      zap.NewNop(),
		batchSize:   defaultBatchSize,
		concurrency: runtime.GOMAXPROCS(0),
	}
}
116056
func NewCmd(ctx context.Context, args ...string) (cmd *Cmd) {
	cmd = &Cmd{
		Args: args,
		ctx:  ctx,
	}
	return
}
1261260
func NewCommand(ctx Context, name string) (cmd.Command, error) {
	f := allEnabledCommands()[name]
	if f == nil {
		return nil, errors.Errorf("unknown command: %s", name)
	}
	command, err := f(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return command, nil
}
252142
func NewEnableCommand() cmd.Command {
	return modelcmd.Wrap(&enableCommand{
		apiFunc: func(c newAPIRoot) (unblockClientAPI, error) {
			return getBlockAPI(c)
		},
	})
}
1060246
func NewEngineCommand(dockerCli command.Cli) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "engine COMMAND",
		Short: "Manage the docker engine",
		Args:  cli.NoArgs,
		RunE:  command.ShowHelp(dockerCli.Err()),
	}
	cmd.AddCommand(
		newActivateCommand(dockerCli),
		newCheckForUpdatesCommand(dockerCli),
		newUpdateCommand(dockerCli),
	)
	return cmd
}
873029
func NewCmd(cmdLine string) (*Cmd, error) {

	parseCmd, err := shellwords.Parse(cmdLine)
	if err != nil {
		return nil, err
	}
	return &Cmd{Cmd: exec.Command(parseCmd[0], parseCmd[1:]...)}, nil
}
1174009
func (c *Command) Subcommand(name string) *Command {
	for _, sub := range c.Subcommands {
		if sub.Name == name {
			return sub
		}
		for _, a := range sub.Aliases {
			if a == name {
				return sub
			}
		}
	}
	return nil
}
415094
func newCommandConn(args []string, cli *client.Client) (command, error) {
	// Create a flag set.
	var flg flag.FlagSet

	// Define the flags.
	network := flg.String("n", defaultNetwork, "network on which the Client connects to the Server")
	host := flg.String("h", defaultHost, "host name of the Server which the Client connects to")
	port := flg.Uint("p", defaultPort, "port number of the Server which the Client connects to")
	crtPath := flg.String("crt", "", "the path of the certificate authority file to verify the server connection")
	connackTimeout := flg.Uint(
		"ct",
		defaultCONNACKTimeout,
		"Timeout in seconds for the Client to wait for receiving the CONNACK Packet after sending the CONNECT Packet",
	)
	pingrespTimeout := flg.Uint(
		"pt",
		defaultPINGRESPTimeout,
		"Timeout in seconds for the Client to wait for receiving the PINGRESP Packet after sending the PINGREQ Packet",
	)
	clientID := flg.String("i", "", "Client identifier for the Client")
	userName := flg.String("u", "", "User Name")
	password := flg.String("P", "", "Password")
	cleanSession := flg.Bool("c", defaultCleanSession, "Clean Session")
	keepAlive := flg.Uint("k", defaultKeepAlive, "Keep Alive measured in seconds")
	willTopic := flg.String("wt", "", "Will Topic")
	willMessage := flg.String("wm", "", "Will Message")
	willQoS := flg.Uint("wq", uint(mqtt.QoS0), "Will QoS")
	willRetain := flg.Bool("wr", false, "Will Retain")

	// Parse the flag.
	if err := flg.Parse(args); err != nil {
		return nil, errCmdArgsParse
	}

	var tlsConfig *tls.Config

	// Parse the certificate authority file.
	if *crtPath != "" {
		b, err := ioutil.ReadFile(*crtPath)
		if err != nil {
			return nil, err
		}

		roots := x509.NewCertPool()
		if ok := roots.AppendCertsFromPEM(b); !ok {
			return nil, errParseCrtFailure
		}

		tlsConfig = &tls.Config{
			RootCAs: roots,
		}
	}

	// Create a conn command.
	cmd := &commandConn{
		cli: cli,
		connectOpts: &client.ConnectOptions{
			Network:         *network,
			Address:         *host + ":" + strconv.Itoa(int(*port)),
			TLSConfig:       tlsConfig,
			CONNACKTimeout:  time.Duration(*connackTimeout),
			PINGRESPTimeout: time.Duration(*pingrespTimeout),
			ClientID:        []byte(*clientID),
			UserName:        []byte(*userName),
			Password:        []byte(*password),
			CleanSession:    *cleanSession,
			KeepAlive:       uint16(*keepAlive),
			WillTopic:       []byte(*willTopic),
			WillMessage:     []byte(*willMessage),
			WillQoS:         byte(*willQoS),
			WillRetain:      *willRetain,
		},
	}

	// Return the command.
	return cmd, nil
}
660426
func NewCommand() *cobra.Command {
	var command = &cobra.Command{
		Use:   CLIName,
		Short: "argo is the command line interface to Argo",
		Run: func(cmd *cobra.Command, args []string) {
			cmd.HelpFunc()(cmd, args)
		},
	}

	command.AddCommand(NewCompletionCommand())
	command.AddCommand(NewDeleteCommand())
	command.AddCommand(NewGetCommand())
	command.AddCommand(NewLintCommand())
	command.AddCommand(NewListCommand())
	command.AddCommand(NewLogsCommand())
	command.AddCommand(NewResubmitCommand())
	command.AddCommand(NewResumeCommand())
	command.AddCommand(NewRetryCommand())
	command.AddCommand(NewSubmitCommand())
	command.AddCommand(NewSuspendCommand())
	command.AddCommand(NewWaitCommand())
	command.AddCommand(NewWatchCommand())
	command.AddCommand(NewTerminateCommand())
	command.AddCommand(cmd.NewVersionCmd(CLIName))

	addKubectlFlagsToCmd(command)
	return command
}
1357206
func newCommand(name string, data []byte) (Command, error) {
	// Find the registered command.
	command := commandTypes[name]
	if command == nil {
		return nil, fmt.Errorf("raft.Command: Unregistered command type: %s", name)
	}

	// Make a copy of the command.
	v := reflect.New(reflect.Indirect(reflect.ValueOf(command)).Type()).Interface()
	copy, ok := v.(Command)
	if !ok {
		panic(fmt.Sprintf("raft: Unable to copy command: %s (%v)", command.CommandName(), reflect.ValueOf(v).Kind().String()))
	}

	// If data for the command was passed in the decode it.
	if data != nil {
		if encoder, ok := copy.(CommandEncoder); ok {
			if err := encoder.Decode(bytes.NewReader(data)); err != nil {
				return nil, err
			}
		} else {
			if err := json.NewDecoder(bytes.NewReader(data)).Decode(copy); err != nil {
				return nil, err
			}
		}
	}

	return copy, nil
}
318502
func NewCommand(p *Program) *cobra.Command {
	var cmd = &cobra.Command{
		Use:  p.Name,
		Args: cobra.NoArgs,
		RunE: func(_ *cobra.Command, _ []string) error {
			return p.Run()
		},
	}

	viper.SetEnvPrefix(strings.ToUpper(p.Name))
	viper.AutomaticEnv()
	// This normalizes "-" to an underscore in env names.
	viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))

	for _, o := range p.Opts {
		switch o.DestP.(type) {
		case *string:
			if o.Default == nil {
				o.Default = ""
			}
			cmd.Flags().StringVar(o.DestP.(*string), o.Flag, o.Default.(string), o.Desc)
			viper.BindPFlag(o.Flag, cmd.Flags().Lookup(o.Flag))
			*o.DestP.(*string) = viper.GetString(o.Flag)
		case *int:
			if o.Default == nil {
				o.Default = 0
			}
			cmd.Flags().IntVar(o.DestP.(*int), o.Flag, o.Default.(int), o.Desc)
			viper.BindPFlag(o.Flag, cmd.Flags().Lookup(o.Flag))
			*o.DestP.(*int) = viper.GetInt(o.Flag)
		case *bool:
			if o.Default == nil {
				o.Default = false
			}
			cmd.Flags().BoolVar(o.DestP.(*bool), o.Flag, o.Default.(bool), o.Desc)
			viper.BindPFlag(o.Flag, cmd.Flags().Lookup(o.Flag))
			*o.DestP.(*bool) = viper.GetBool(o.Flag)
		case *time.Duration:
			if o.Default == nil {
				o.Default = time.Duration(0)
			}
			cmd.Flags().DurationVar(o.DestP.(*time.Duration), o.Flag, o.Default.(time.Duration), o.Desc)
			viper.BindPFlag(o.Flag, cmd.Flags().Lookup(o.Flag))
			*o.DestP.(*time.Duration) = viper.GetDuration(o.Flag)
		case *[]string:
			if o.Default == nil {
				o.Default = []string{}
			}
			cmd.Flags().StringSliceVar(o.DestP.(*[]string), o.Flag, o.Default.([]string), o.Desc)
			viper.BindPFlag(o.Flag, cmd.Flags().Lookup(o.Flag))
			*o.DestP.(*[]string) = viper.GetStringSlice(o.Flag)
		default:
			// if you get a panic here, sorry about that!
			// anyway, go ahead and make a PR and add another type.
			panic(fmt.Errorf("unknown destination type %t", o.DestP))
		}
	}

	return cmd
}
133404
func newCommand(cmdName string, cmdArgs []string, cli *client.Client) (command, error) {
	switch cmdName {
	case cmdNameConn:
		return newCommandConn(cmdArgs, cli)
	case cmdNameDisconn:
		return newCommandDisconn(cli), nil
	case cmdNameHelp:
		return newCommandHelp(), nil
	case cmdNamePub:
		return newCommandPub(cmdArgs, cli)
	case cmdNameQuit:
		return newCommandQuit(cli), nil
	case cmdNameSub:
		return newCommandSub(cmdArgs, cli)
	case cmdNameUnsub:
		return newCommandUnsub(cmdArgs, cli)
	}

	return nil, errInvalidCmdName
}