Hide sub-tree when parent is hidden.
This commit is contained in:
@@ -67,7 +67,7 @@ func printApp(w *helpWriter, app *Application) {
|
|||||||
if !w.NoAppSummary {
|
if !w.NoAppSummary {
|
||||||
w.Printf("Usage: %s%s", app.Name, app.Summary())
|
w.Printf("Usage: %s%s", app.Name, app.Summary())
|
||||||
}
|
}
|
||||||
printNodeDetail(w, app.Node)
|
printNodeDetail(w, app.Node, true)
|
||||||
cmds := app.Leaves(true)
|
cmds := app.Leaves(true)
|
||||||
if len(cmds) > 0 && app.HelpFlag != nil {
|
if len(cmds) > 0 && app.HelpFlag != nil {
|
||||||
w.Print("")
|
w.Print("")
|
||||||
@@ -83,14 +83,14 @@ func printCommand(w *helpWriter, app *Application, cmd *Command) {
|
|||||||
if !w.NoAppSummary {
|
if !w.NoAppSummary {
|
||||||
w.Printf("Usage: %s %s", app.Name, cmd.Summary())
|
w.Printf("Usage: %s %s", app.Name, cmd.Summary())
|
||||||
}
|
}
|
||||||
printNodeDetail(w, cmd)
|
printNodeDetail(w, cmd, false)
|
||||||
if w.Summary && app.HelpFlag != nil {
|
if w.Summary && app.HelpFlag != nil {
|
||||||
w.Print("")
|
w.Print("")
|
||||||
w.Printf(`Run "%s --help" for more information.`, cmd.FullPath())
|
w.Printf(`Run "%s --help" for more information.`, cmd.FullPath())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printNodeDetail(w *helpWriter, node *Node) {
|
func printNodeDetail(w *helpWriter, node *Node, hide bool) {
|
||||||
if node.Help != "" {
|
if node.Help != "" {
|
||||||
w.Print("")
|
w.Print("")
|
||||||
w.Wrap(node.Help)
|
w.Wrap(node.Help)
|
||||||
@@ -112,7 +112,7 @@ func printNodeDetail(w *helpWriter, node *Node) {
|
|||||||
w.Print("Flags:")
|
w.Print("Flags:")
|
||||||
writeFlags(w.Indent(), flags)
|
writeFlags(w.Indent(), flags)
|
||||||
}
|
}
|
||||||
cmds := node.Leaves(true)
|
cmds := node.Leaves(hide)
|
||||||
if len(cmds) > 0 {
|
if len(cmds) > 0 {
|
||||||
w.Print("")
|
w.Print("")
|
||||||
w.Print("Commands:")
|
w.Print("Commands:")
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ func (n *Node) Leaves(hide bool) (out []*Node) {
|
|||||||
}
|
}
|
||||||
if node, ok := nd.(*Node); ok {
|
if node, ok := nd.(*Node); ok {
|
||||||
if hide && node.Hidden {
|
if hide && node.Hidden {
|
||||||
return next(nil)
|
return nil
|
||||||
}
|
}
|
||||||
if len(node.Children) == 0 && node.Type != ApplicationNode {
|
if len(node.Children) == 0 && node.Type != ApplicationNode {
|
||||||
out = append(out, node)
|
out = append(out, node)
|
||||||
|
|||||||
Reference in New Issue
Block a user