make HelperOptions CommandTree method exported

This commit is contained in:
Rene Zbinden
2020-02-18 21:47:05 +01:00
committed by Alec Thomas
parent ada7d7bf11
commit af533a38fb
+4 -4
View File
@@ -176,7 +176,7 @@ func writeCommandTree(w *helpWriter, node *Node) {
if cmd.Hidden { if cmd.Hidden {
continue continue
} }
rows = append(rows, w.commandTree(cmd, "")...) rows = append(rows, w.CommandTree(cmd, "")...)
if i != len(node.Children)-1 { if i != len(node.Children)-1 {
rows = append(rows, [2]string{"", ""}) rows = append(rows, [2]string{"", ""})
} }
@@ -349,8 +349,8 @@ func formatFlag(haveShort bool, flag *Flag) string {
return flagString return flagString
} }
// commandTree creates a tree with the given node name as root and its children's arguments and sub commands as leaves. // CommandTree creates a tree with the given node name as root and its children's arguments and sub commands as leaves.
func (h *HelpOptions) commandTree(node *Node, prefix string) (rows [][2]string) { func (h *HelpOptions) CommandTree(node *Node, prefix string) (rows [][2]string) {
var nodeName string var nodeName string
switch node.Type { switch node.Type {
default: default:
@@ -368,7 +368,7 @@ func (h *HelpOptions) commandTree(node *Node, prefix string) (rows [][2]string)
rows = append(rows, [2]string{prefix + arg.Summary(), arg.Help}) rows = append(rows, [2]string{prefix + arg.Summary(), arg.Help})
} }
for _, subCmd := range node.Children { for _, subCmd := range node.Children {
rows = append(rows, h.commandTree(subCmd, prefix)...) rows = append(rows, h.CommandTree(subCmd, prefix)...)
} }
return return
} }