// Subcmd is borrowed from Docker UI and performs the same function of configuring the subCmds
543895
func (cli *NetworkCli) Subcmd(chain, name, signature, description string, exitOnError bool) *flag.FlagSet {
	var errorHandling flag.ErrorHandling
	if exitOnError {
		errorHandling = flag.ExitOnError
	} else {
		errorHandling = flag.ContinueOnError
	}
	flags := flag.NewFlagSet(name, errorHandling)
	flags.Usage = func() {
		flags.ShortUsage()
		flags.PrintDefaults()
	}
	flags.ShortUsage = func() {
		options := ""
		if signature != "" {
			signature = " " + signature
		}
		if flags.FlagCountUndeprecated() > 0 {
			options = " [OPTIONS]"
		}
		fmt.Fprintf(cli.out, "\nUsage: %s %s%s%s\n\n%s\n\n", chain, name, options, signature, description)
		flags.SetOutput(cli.out)
	}
	return flags
}
617353
func Cmd(params base.Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "generate SCRIPT",
		ShortDesc: "interprets a high-level config, generating *.cfg files",
		LongDesc: `Interprets a high-level config, generating *.cfg files.

Writes generated configs to the directory given via -config-dir or via
lucicfg.config(config_dir=...) statement in the script. If it is '-', just
prints them to stdout.

If -validate is given, sends the generated config to LUCI Config service for
validation. This can also be done separately via 'validate' subcommand.

If the generation stage fails, doesn't overwrite any files on disk. If the
generation succeeds, but the validation fails, the new generated files are kept
on disk, so they can be manually examined for reasons they are invalid.
`,
		CommandRun: func() subcommands.CommandRun {
			gr := &generateRun{}
			gr.Init(params)
			gr.AddMetaFlags()
			gr.Flags.BoolVar(&gr.validate, "validate", false, "Validate the generate configs by sending them to LUCI Config")
			return gr
		},
	}
}
668172
func Cmd(cf *LoggingCmdFactory) *cobra.Command {
	loggingCmd.AddCommand(getLevelCmd(cf))
	loggingCmd.AddCommand(setLevelCmd(cf))
	loggingCmd.AddCommand(revertLevelsCmd(cf))
	loggingCmd.AddCommand(getLogSpecCmd(cf))
	loggingCmd.AddCommand(setLogSpecCmd(cf))

	return loggingCmd
}
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
}
710803
func (ftp *FTP) cmd(expects string, command string, args ...interface{}) (line string, err error) {
	if err = ftp.send(command, args...); err != nil {
		return
	}

	if line, err = ftp.receive(); err != nil {
		return
	}

	if !strings.HasPrefix(line, expects) {
		err = errors.New(line)
		return
	}

	return
}
326676
func (g *Git) Cmd(context.Context, string, ...string) error {
	return fmt.Errorf("not supported")
}
1182756
func NewSystemCommand(dockerCli command.Cli) *cobra.Command {
	cmd := &cobra.Command{
		Use:   "system",
		Short: "Manage Docker",
		Args:  cli.NoArgs,
		RunE:  command.ShowHelp(dockerCli.Err()),
	}
	cmd.AddCommand(
		NewEventsCommand(dockerCli),
		NewInfoCommand(dockerCli),
		newDiskUsageCommand(dockerCli),
		newPruneCommand(dockerCli),
		newDialStdioCommand(dockerCli),
	)

	return cmd
}
1140870
func cmd(dir string, arg ...string) (string, error) {
	c := exec.Command(binary, arg...)
	c.Dir = dir

	output, err := c.CombinedOutput()
	if err != nil {
		return "", fmt.Errorf("running `%s %s` failed with output: %s\nerror: %v", c.Path, strings.Join(c.Args, " "), output, err)
	}

	return string(output), nil
}
1272358
func filecmd(h FileCmder, r *Request, pkt requestPacket) responsePacket {

	switch p := pkt.(type) {
	case *sshFxpFsetstatPacket:
		r.Flags = p.Flags
		r.Attrs = p.Attrs.([]byte)
	}
	err := h.Filecmd(r)
	return statusFromError(pkt, err)
}
51244
func (ftp *FTP) RawCmd(command string, args ...interface{}) (code int, line string) {
	if ftp.debug {
		log.Printf("Raw-> %s\n", fmt.Sprintf(command, args...))
	}

	code = -1
	var err error
	if err = ftp.send(command, args...); err != nil {
		return code, ""
	}
	if line, err = ftp.receive(); err != nil {
		return code, ""
	}
	code, err = strconv.Atoi(line[:3])
	if ftp.debug {
		log.Printf("Raw<-	<- %d \n", code)
	}
	return code, line
}
97064
func RunCmd(in io.Reader, out, err io.Writer, args ...string) error {
	if len(args) == 0 {
		panic("no command to run")
	}

	name := args[0]
	if filepath.Base(name) == name {
		if lp, err := exec.LookPath(name); err != nil {
			return err
		} else {
			name = lp
		}
	}

	return (&exec.Cmd{
		Path:   name,
		Args:   args,
		Stdin:  in,
		Stdout: out,
		Stderr: err,
	}).Run()
}
436917
func configureCommand() *cli.Command {
	return &cli.Command{
		Name:  configureCommandName,
		Usage: configureCommandUsage,
		Action: func(c *cli.Context) (err error) {
			return configActionRunner{
				context: c,

				generateConfig: generateConfig,
				loadConfigs:    gocd.LoadConfigFromFile,
				writeConfigs:   writeConfigsToFile,
			}.run()
		},
		Flags: []cli.Flag{
			cli.StringFlag{Name: "profile"},
		},
	}
}
995529
func (c *ServerConn) cmd(expected int, format string, args ...interface{}) (int, string, error) {
	_, err := c.conn.Cmd(format, args...)
	if err != nil {
		return 0, "", err
	}

	return c.conn.ReadResponse(expected)
}
62404
func NewSearchCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "search",
		Short: "Search a RETS server",
		Run:   search,
	}
	cmd.Flags().String(searchFileFlag, "", "Search parameters file location")
	return cmd
}
1352144
func NewSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand {
	var cmd SubCommand
	cmd.init(name, desc, fn, paramNames...)
	return &cmd
}
1301222
func Cmd(params base.Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "validate [CONFIG_DIR|SCRIPT]",
		ShortDesc: "sends configuration files to LUCI Config service for validation",
		LongDesc: `Sends configuration files to LUCI Config service for validation.

If the first positional argument is a directory, takes all files there and
sends them to LUCI Config service, to be validated as a single config set. The
name of the config set (e.g. "projects/foo") MUST be provided via -config-set
flag, it is required in this mode.

If the first positional argument is a Starlark file, it is interpreted (as with
'generate' subcommand) and the resulting generated configs are compared to
what's already on disk in -config-dir directory. If they are different, the
subcommand exits with non-zero exit code (indicating files on disk are stale).
Otherwise the configs are sent to LUCI Config service for validation.
Partitioning into config sets is specified in the Starlark code in this case,
-config-set flag is rejected if given.

When interpreting Starlark script, flags like -config-dir and -fail-on-warnings
work as overrides for values declared in the script via lucicfg.config(...)
statement. See its doc for more details.
		`,
		CommandRun: func() subcommands.CommandRun {
			vr := &validateRun{}
			vr.Init(params)
			vr.AddMetaFlags()
			vr.Flags.StringVar(&vr.configSet, "config-set", "",
				"Name of the config set to validate against when validating existing *.cfg configs.")
			return vr
		},
	}
}
538074
func (c *CLI) SubcommandArgs() []string {
	c.once.Do(c.init)
	return c.subcommandArgs
}