// DefineSubCommand defines and adds a SubCommand on the current command
439252
func (cmd *CLI) DefineSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand {
	return cmd.AddSubCommand(
		NewSubCommand(name, desc, fn, paramNames...),
	)
}
758207
func NewCreateSubcommandOptions(ioStreams genericclioptions.IOStreams) *CreateSubcommandOptions {
	return &CreateSubcommandOptions{
		PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
		IOStreams:  ioStreams,
	}
}
746094
func runSubcommand(command []string, env []string) error {
	binary, lookupErr := exec.LookPath(command[0])
	if lookupErr != nil {
		return lookupErr
	}

	return syscall.Exec(binary, command, env)
}
1305541
func (cmd *CLI) SubCommandsUsageString(title string) string {
	tbl := NewSharedShellTable(&sep, &columnWidth)
	cmd.subCommands.Each(func(name string, command *SubCommand) {
		row := tbl.Row()
		row.Column(" ", command.Name())
		aliases := decorateNameAliases(command.NameAliases())
		desArray := []string{command.Description(), aliases}
		description := strings.Join(desArray, "  ")
		row.Column(description)
	})
	return fmt.Sprintf("\n\n%s:\n%s", title, tbl.String())
}
419106
func SubcommandInfo(opts auth.Options, name string, advanced bool) *subcommands.Command {
	return SubcommandInfoWithParams(CommandParams{Name: name, Advanced: advanced, AuthOptions: opts})
}
1199726
func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) {
	ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch}
}
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"},
		},
	}
}
959210
func (a *Application) AddCommand(command Command) {
	a.Commands = append(a.Commands, command)

	newCmd := &a.Commands[len(a.Commands)-1]
	if newCmd.Group != "" {
		group := a.groupByName(newCmd.Group)
		if group == nil {
			panic("group doesn't exist")
		}

		group.Commands = append(group.Commands, newCmd)
	} else {
		a.ungroupedCmdsCount++
	}
}
941764
func (t *Module) MustNewCommand(ctx context.Context) *cobra.Command {
	depModules := ListDeps(0, t)
	depSelfModules := append(depModules, t)

	command := &cobra.Command{
		Use:     t.Use,
		Aliases: t.Aliases,
		Short:   t.Short,
		Long:    t.Long,
		Example: t.Example,
		PreRunE: GenRunE(ctx, depModules...),
		RunE: func(cmd *cobra.Command, args []string) error {
			if t.RunE == nil {
				return nil
			}
			select {
			case <-ctx.Done():
				return nil
			default:
			}
			return t.RunE(ctx, cmd, args)
		},
		PostRunE: GenPostRunE(ctx, depSelfModules...),
	}

	for _, subcmd := range t.Commands {
		subcmd.viper = t.viper
		command.AddCommand(subcmd.MustNewCommand(ctx))
	}

	for _, module := range depSelfModules {
		for _, flag := range module.Flags {
			if err := flag.Bind(command.Flags(), t.viper); err != nil {
				panic(err)
			}
		}
	}

	return command
}
697845
func HelpCommand(desc string) *Command {
	return &Command{
		Name:        "help",
		Desc:        desc,
		CanSubRoute: true,
		NoHook:      true,
		Fn:          HelpCommandFn,
	}
}
928908
func (s *HealthCheck) SetCommand(v []*string) *HealthCheck {
	s.Command = v
	return s
}
703280
func (s *GetSubscriptionDefinitionInput) SetSubscriptionDefinitionId(v string) *GetSubscriptionDefinitionInput {
	s.SubscriptionDefinitionId = &v
	return s
}
1124839
func (cmd *CLI) defineHelp() {
	if _, ok := cmd.flags["help"]; !ok {
		cmd.DefineBoolFlag("help", false, "show help and exit")
		cmd.flagHelp = cmd.flags["help"]
		if _, ok := cmd.aliases['h']; !ok {
			cmd.AliasFlag('h', "help")
		}
	}
}
29125
func addMachineCmd(params *Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "add-machine -name <name> -plat <platform> -rack <rack> -state <state> [-desc <description>] [-atag <asset tag>] [-stag <service tag>] [-tick <deployment ticket>] [-dracpass <DRAC password>]",
		ShortDesc: "adds a machine",
		LongDesc:  "Adds a machine to the database.\n\nExample:\ncrimson add-machine -name xx11-11-720 -plat 'Apple Mac Pro' -rack xx1 -state test -stag BC0001",
		CommandRun: func() subcommands.CommandRun {
			cmd := &AddMachineCmd{}
			cmd.Initialize(params)
			cmd.Flags.StringVar(&cmd.machine.Name, "name", "", "The name of the machine. Required and must be unique within the database.")
			cmd.Flags.StringVar(&cmd.machine.Platform, "plat", "", "The platform type this machine is. Required and must be the name of a platform returned by get-platforms.")
			cmd.Flags.StringVar(&cmd.machine.Rack, "rack", "", "The rack this machine belongs to. Required and must be the name of a rack returned by get-racks.")
			cmd.Flags.Var(StateFlag(&cmd.machine.State), "state", "The state of this machine. Required and must be a state returned by get-states.")
			cmd.Flags.StringVar(&cmd.machine.Description, "desc", "", "A description of this machine.")
			cmd.Flags.StringVar(&cmd.machine.AssetTag, "atag", "", "The asset tag associated with this machine.")
			cmd.Flags.StringVar(&cmd.machine.ServiceTag, "stag", "", "The service tag associated with this machine.")
			cmd.Flags.StringVar(&cmd.machine.DeploymentTicket, "tick", "", "The deployment ticket associated with this machine.")
			cmd.Flags.StringVar(&cmd.machine.DracPassword, "dracpass", "", "The initial DRAC password associated with this machine.")
			return cmd
		},
	}
}
401249
func parseSubCommand(rest string, d *Directive) (*Node, map[string]bool, error) {
	if rest == "" {
		return nil, nil, nil
	}

	child, err := newNodeFromLine(rest, d)
	if err != nil {
		return nil, nil, err
	}

	return &Node{Children: []*Node{child}}, nil, nil
}
1066983
func AddCommand(f Flag, sig os.Signal, handler SignalHandlerFunc) {
	if f != nil {
		AddFlag(f, sig)
	}
	if handler != nil {
		SetSigHandler(handler, sig)
	}
}
698888
func MustCommand(v interface{}) *exec.Cmd {
	if command, err := Command(v); err == nil {
		return command
	} else {
		panic(err.Error())
	}
}