提交 589851fb 作者: Juan Batiz-Benet

cmds: root: fix '--help' notice for subcmds

上级 a4488cab
...@@ -33,6 +33,7 @@ type helpFields struct { ...@@ -33,6 +33,7 @@ type helpFields struct {
Synopsis string Synopsis string
Subcommands string Subcommands string
Description string Description string
MoreHelp bool
} }
// TrimNewlines removes extra newlines from fields. This makes aligning // TrimNewlines removes extra newlines from fields. This makes aligning
...@@ -105,7 +106,8 @@ SYNOPSIS ...@@ -105,7 +106,8 @@ SYNOPSIS
{{end}}{{if .Description}} {{end}}{{if .Description}}
{{.Description}} {{.Description}}
{{end}} {{end}}
Use '{{.Path}} --help' for more information about this command. {{if .MoreHelp}}Use '{{.Path}} --help' for more information about this command.
{{end}}
` `
var usageTemplate *template.Template var usageTemplate *template.Template
...@@ -141,6 +143,7 @@ func LongHelp(rootName string, root *cmds.Command, path []string, out io.Writer) ...@@ -141,6 +143,7 @@ func LongHelp(rootName string, root *cmds.Command, path []string, out io.Writer)
Subcommands: cmd.Helptext.Subcommands, Subcommands: cmd.Helptext.Subcommands,
Description: cmd.Helptext.ShortDescription, Description: cmd.Helptext.ShortDescription,
Usage: cmd.Helptext.Usage, Usage: cmd.Helptext.Usage,
MoreHelp: (cmd != root),
} }
if len(cmd.Helptext.LongDescription) > 0 { if len(cmd.Helptext.LongDescription) > 0 {
...@@ -192,6 +195,7 @@ func ShortHelp(rootName string, root *cmds.Command, path []string, out io.Writer ...@@ -192,6 +195,7 @@ func ShortHelp(rootName string, root *cmds.Command, path []string, out io.Writer
Synopsis: cmd.Helptext.Synopsis, Synopsis: cmd.Helptext.Synopsis,
Description: cmd.Helptext.ShortDescription, Description: cmd.Helptext.ShortDescription,
Usage: cmd.Helptext.Usage, Usage: cmd.Helptext.Usage,
MoreHelp: (cmd != root),
} }
// trim the extra newlines (see TrimNewlines doc) // trim the extra newlines (see TrimNewlines doc)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论