// AddSubCommand adds a subcommand to a command
2839
func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand {
	subcmd.ErrorHandling = cmd.ErrorHandling
	cmd.subCommands.Add(subcmd.name, subcmd)
	if subcmd.parent != nil {
		panic("command already assigned")
	}
	if &subcmd.CLI == cmd {
		panic("cannot assign subcmd to itself as a subcmd")
	}
	subcmd.parent = cmd
	return subcmd
}
901227
func addDRACCmd(params *Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "add-drac -name <name> -machine <machine> -mac <mac address> -switch <switch> -port <port> -ip <ip address>",
		ShortDesc: "adds a DRAC",
		LongDesc:  "Adds a DRAC to the database.\n\nExample:\ncrimson add-drac -name server01-yy-drac -machine xx1-07-720 -mac 00:00:b3:c0:00:11 -switch switch.lab0 -port 99 -ip 999.999.999.999",
		CommandRun: func() subcommands.CommandRun {
			cmd := &AddDRACCmd{}
			cmd.Initialize(params)
			cmd.Flags.StringVar(&cmd.drac.Name, "name", "", "The name of the DRAC. Required and must be unique per machine within the database.")
			cmd.Flags.StringVar(&cmd.drac.Machine, "machine", "", "The machine this DRAC belongs to. Required and must be the name of a machine returned by get-machines.")
			cmd.Flags.StringVar(&cmd.drac.MacAddress, "mac", "", "The MAC address of this DRAC. Required and must be a valid MAC-48 address.")
			cmd.Flags.StringVar(&cmd.drac.Switch, "switch", "", "The switch this DRAC is connected to. Required and must be the name of a switch returned by get-switches.")
			cmd.Flags.Var(flag.Int32(&cmd.drac.Switchport), "port", "The switchport this DRAC is connected to.")
			cmd.Flags.StringVar(&cmd.drac.Ipv4, "ip", "", "The IPv4 address assigned to this DRAC. Required and must be a free IP address returned by get-ips.")
			return cmd
		},
	}
}
861596
func (c Client) AddSubscription(s contract.Subscription) (string, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	err := addSubscription(conn, &s)
	if err != nil {
		return "", err
	}

	return s.ID, nil
}
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
	}
}
538074
func (c *CLI) SubcommandArgs() []string {
	c.once.Do(c.init)
	return c.subcommandArgs
}
302585
func (c *CLI) subcommandParent() string {
	// Get the subcommand, if it is "" alread just return
	sub := c.Subcommand()
	if sub == "" {
		return sub
	}

	// Clear any trailing spaces and find the last space
	sub = strings.TrimRight(sub, " ")
	idx := strings.LastIndex(sub, " ")

	if idx == -1 {
		// No space means our parent is root
		return ""
	}

	return sub[:idx]
}
1352144
func NewSubCommand(name string, desc string, fn func(Command), paramNames ...string) *SubCommand {
	var cmd SubCommand
	cmd.init(name, desc, fn, paramNames...)
	return &cmd
}
1329680
func (s *ClusterRerouteService) Add(commands ...AllocationCommand) *ClusterRerouteService {
	s.commands = append(s.commands, commands...)
	return s
}
60874
func (c *Cmd) AddCmd(cmd *Cmd) {
	if c.children == nil {
		c.children = make(map[string]*Cmd)
	}
	c.children[cmd.Name] = cmd
}
537241
func (p *Pipeline) Add(cmd ...*Command) {
	p.commands = append(p.commands, cmd...)
}
1113935
func (cmd *Command) MustRegisterSubcommand(subcmd *Command) {
	// Require some fields to be non-empty.
	switch {
	case subcmd.Short == "":
		panic("Short not set")
	case subcmd.UsageLine == "":
		panic("UsageLine not set")
	}

	// Fill in the unexported fields.
	subcmd.helpTemplate = CommandHelpTemplate
	subcmd.helpTemplateData = subcmd

	// Print help if there is no action defined.
	if subcmd.Action == nil {
		subcmd.Action = helpAction(1)
	}

	// Define the help flag.
	subcmd.Flags.Var((*helpValue)(subcmd), "h", "print help and exit")

	// Easy if there are no subcommands defined yet.
	if cmd.Subcmds == nil {
		cmd.Subcmds = []*Command{subcmd}
		return
	}

	// Check for subcommand name collisions.
	for _, c := range cmd.Subcmds {
		if c.Name() == subcmd.Name() {
			panic(fmt.Sprintf("Subcommand %s already defined", subcmd.Name))
		}
	}

	cmd.Subcmds = append(cmd.Subcmds, subcmd)
}
452542
func (pmux *PubSubMux) AddSubCh(channel string, ch chan interface{}) {
	pmux.muxLock.Lock()
	defer pmux.muxLock.Unlock()

	p, ok := pmux.mux[channel]
	if !ok {
		p = newPubSub()
		pmux.mux[channel] = p
	}
	select {
	case p.addDst <- ch:
	case <-time.After(1 * time.Second):
		log.Printf("pubSub timedout writing to addDst")
	}
}
1113976
func NewAddNodeCmd(addr string, subCmd AddNodeSubCmd) *AddNodeCmd {
	return &AddNodeCmd{
		Addr:   addr,
		SubCmd: subCmd,
	}
}
505483
func (c *MenuOption) AddToSubMenu(sub *MenuOption) {
	c.subMenu = append(c.subMenu, *sub)
}
383784
func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string) {
	return func(c *cobra.Command, args []string) {
		c.SetOutput(out)
		RequireNoArguments(c, args)
		c.Help()
		CheckErr(ErrExit)
	}
}
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++
	}
}
1365518
func (h *SMTPAPIHeader) AddSubstitutions(key string, subs []string) {
	for i := 0; i < len(subs); i++ {
		h.AddSubstitution(key, subs[i])
	}
}