// RegisterTree registers a command tree
336120
func (cmd *Command) RegisterTree(forest ...*CommandTree) {
	for _, tree := range forest {
		cmd.Register(tree.command)
		if tree.forest != nil && len(tree.forest) > 0 {
			tree.command.RegisterTree(tree.forest...)
		}
	}
}
445679
func (r *Router) Register(path string, runner Runner, desc string) {
	a, e := newAction(path, runner, desc)
	if e != nil {
		fmt.Fprintln(DefaultWriter, e)
		r.initFailed = true
		return
	}

	pathSegments := strings.Split(a.path, "/")
	node, pathSegments := r.findNode(pathSegments, false)
	if node != nil {
		if node.action != nil {
			fmt.Fprintf(DefaultWriter, "failed to register action for path %q: action for path %q already registered\n", a.path, node.action.path)
			r.initFailed = true
			return
		} else if len(pathSegments) == 0 && len(node.children) > 0 {
			fmt.Fprintf(DefaultWriter, "failed to register action for path %q: longer paths with this prefix exist\n", a.path)
			r.initFailed = true
			return
		}
	} else {
		node = r.root
	}

	for _, p := range pathSegments {
		newNode := &routingTreeNode{children: map[string]*routingTreeNode{}}
		node.children[p] = newNode
		node = newNode
	}

	node.action = a
}
97451
func (s *MockStore) DeleteTree(prefix string) error {
	delete(s.db, prefix)
	return nil
}
212664
func (w *TreeWalker) Tree() *Tree {
	current := len(w.stack) - 1
	if w.stack[current].pos == 0 {
		current--
	}

	if current < 0 {
		return nil
	}

	return w.stack[current].t
}
1113798
func (res *Resource) RouteTree() string {
	var routes string

	for _, route := range res.Routes {
		routes = strings.Join([]string{routes, route}, "\n")
	}

	return routes
}
893652
func (cmd *Command) RegisterFunc(name string, fn CommandFunc, argvFn ArgvFunc) *Command {
	return cmd.Register(&Command{Name: name, Fn: fn, Argv: argvFn})
}
176323
func (cmd *CreateAccountCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {
	cc.Flags().StringVar(&cmd.Payload, "payload", "", "Request body encoded in JSON")
	cc.Flags().StringVar(&cmd.ContentType, "content", "", "Request content type override, e.g. 'application/x-www-form-urlencoded'")
}
710819
func (n *Node) registerNode(node *api.RaftMember) error {
	if n.cluster.IsIDRemoved(node.RaftID) {
		return nil
	}

	member := &membership.Member{}

	existingMember := n.cluster.GetMember(node.RaftID)
	if existingMember != nil {
		// Member already exists

		// If the address is different from what we thought it was,
		// update it. This can happen if we just joined a cluster
		// and are adding ourself now with the remotely-reachable
		// address.
		if existingMember.Addr != node.Addr {
			if node.RaftID != n.Config.ID {
				if err := n.transport.UpdatePeer(node.RaftID, node.Addr); err != nil {
					return err
				}
			}
			member.RaftMember = node
			n.cluster.AddMember(member)
		}

		return nil
	}

	// Avoid opening a connection to the local node
	if node.RaftID != n.Config.ID {
		if err := n.transport.AddPeer(node.RaftID, node.Addr); err != nil {
			return err
		}
	}

	member.RaftMember = node
	err := n.cluster.AddMember(member)
	if err != nil {
		if rerr := n.transport.RemovePeer(node.RaftID); rerr != nil {
			return errors.Wrapf(rerr, "failed to remove peer after error %v", err)
		}
		return err
	}

	return nil
}
414169
func (c *Commit) Tree() (*Tree, error) {
	return GetTree(c.s, c.TreeHash)
}
590215
func (r *RootCMD) RegisterCMD(c *CMD) {
	// Set up the command
	if r.Subcommands == nil {
		r.Subcommands = make(map[string]*CMD)
	}
	r.Subcommands[c.Name] = c

	// Set up the alias
	if r.Aliases == nil {
		r.Aliases = make(map[string]string)
	}
	r.Aliases[c.Alias] = c.Name
}
1019747
func registerFlags(c *cli.Config, f *flag.FlagSet) {
	f.StringVar(&c.CertFile, "cert", "", "Client certificate that contains the public key")
	f.StringVar(&c.Domain, "domain", "", "remote server domain name")
	f.StringVar(&c.Serial, "serial", "", "certificate serial number")
	f.StringVar(&c.AKI, "aki", "", "certificate issuer (authority) key identifier")
	f.StringVar(&c.DBConfigFile, "db-config", "", "certificate db configuration file")
}
1362043
func (tree *tree) Dispose() {
	tree.actions.Dispose()
	atomic.StoreUint64(&tree.disposed, 1)
}
285272
func (cmd *ListBottleCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {
	var accountID int
	cc.Flags().IntVar(&cmd.AccountID, "accountID", accountID, `Account ID`)
	var years []int
	cc.Flags().IntSliceVar(&cmd.Years, "years", years, `Filter by years`)
}
1267012
func (conf *PluginConfig) registerKey(key string) string {
	if _, exists := conf.validKeys[key]; exists {
		return key // ### return, already registered ###
	}

	// Remove array notation from path
	path := key
	startIdx := strings.IndexRune(path, tcontainer.MarshalMapArrayBegin)
	for startIdx > -1 {
		if endIdx := strings.IndexRune(path[startIdx:], tcontainer.MarshalMapArrayEnd); endIdx > -1 {
			path = path[0:startIdx] + path[startIdx+endIdx+1:]
			startIdx = strings.IndexRune(path, tcontainer.MarshalMapArrayBegin)
		} else {
			startIdx = -1
		}
	}

	if _, exists := conf.validKeys[path]; exists {
		return key // ### return, already registered (without array notation) ###
	}

	// Register all parts of the path
	startIdx = strings.IndexRune(path, tcontainer.MarshalMapSeparator)
	cutIdx := startIdx
	for startIdx > -1 {
		conf.validKeys[path[:cutIdx]] = true
		startIdx = strings.IndexRune(path[startIdx+1:], tcontainer.MarshalMapSeparator)
		cutIdx += startIdx
	}

	conf.validKeys[path] = true
	return key
}
130320
func (e *Encoder) nextTree() *Tree {
	return newTreeWithPosition(Position{Line: e.line, Col: 1})
}
650463
func Root(root *Command, forest ...*CommandTree) *Command {
	root.RegisterTree(forest...)
	return root
}
944169
func RegisterMode(mode string, makeCmd func(Flags *flag.FlagSet) CommandRunner) {
	if _, dup := modeCommand[mode]; dup {
		log.Fatalf("duplicate command %q registered", mode)
	}
	flags := flag.NewFlagSet(mode+" options", flag.ContinueOnError)
	flags.Usage = func() {}

	var cmdHelp bool
	flags.BoolVar(&cmdHelp, "help", false, "Help for this mode.")
	wantHelp[mode] = &cmdHelp
	modeFlags[mode] = flags
	modeCommand[mode] = makeCmd(flags)
}