Merge pull request #122 from eparis/cleanups
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Update help template
authored by Eric Paris · committed by Eric Paris · parents 8e12710, f453e87 · Browse files · 1 file·+31 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+31 added−23 removed
- other:+31 added−23 removed
Provenance
- Commit
385fc87- Tree
a247c72- Author
Eric Paris <eparis@redhat.com>- Committer
Eric Paris <eparis@redhat.com>- Parent 1
8e12710- Parent 2
f453e87
1 file changed+31 added−23 removed
modified:command.go+31 added-23 removed
257 unmodified lines258 {{.NameAndAliases}}259 {{end}}{{if .HasExample}}260 261 Examples:262-{{ .Example }}263-{{end}}{{ if .HasRunnableSubCommands}}262+{{ .Example }}{{end}}{{ if .HasNonHelpSubCommands}}263 265-Available Commands: {{range .Commands}}{{if and (.Runnable) (not .Deprecated)}}266- {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}267-{{end}}268-{{ if .HasLocalFlags}}Flags:269-{{.LocalFlags.FlagUsages}}{{end}}270-{{ if .HasInheritedFlags}}Global Flags:271-{{.InheritedFlags.FlagUsages}}{{end}}{{if or (.HasHelpSubCommands) (.HasRunnableSiblings)}}272-Additional help topics:273-{{if .HasHelpSubCommands}}{{range .Commands}}{{if and (not .Runnable) (not .Deprecated)}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasRunnableSiblings }}{{range .Parent.Commands}}{{if and (not .Runnable) (not .Deprecated)}}{{if not (eq .Name $cmd.Name) }}274- {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{end}}275-{{end}}{{ if .HasSubCommands }}264+Available Commands: {{range .Commands}}{{if (not .IsHelpCommand)}}265+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasLocalFlags}}266+267+Flags:268+{{.LocalFlags.FlagUsages}}{{end}}{{ if .HasInheritedFlags}}269+270+Global Flags:271+{{.InheritedFlags.FlagUsages}}{{end}}{{if .HasHelpSubCommands}}272+273+Additional help topics: {{range .Commands}}{{if .IsHelpCommand}}274+ {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}}{{end}}{{end}}{{ if .HasSubCommands }}275+276 Use "{{.CommandPath}} [command] --help" for more information about a command.277 {{end}}`278 }279 }522 unmodified lines802 func (c *Command) HasSubCommands() bool {803 return len(c.commands) > 0804 }805 806-func (c *Command) HasRunnableSiblings() bool {807- if !c.HasParent() {806+func (c *Command) IsHelpCommand() bool {807+ if c.Runnable() {808 return false809 }810- for _, sub := range c.parent.commands {811- if sub.Runnable() {812- return true810+ for _, sub := range c.commands {811+ if len(sub.Deprecated) != 0 {812+ continue813 }814+ if !sub.IsHelpCommand() {815+ return false816+ }817 }815- return false818+ return true819 }820 821 func (c *Command) HasHelpSubCommands() bool {822 for _, sub := range c.commands {820- if !sub.Runnable() {823+ if len(sub.Deprecated) != 0 {824+ continue825+ }826+ if sub.IsHelpCommand() {827 return true828 }829 }830 return false831 }832 827-// Determine if the command has runnable children commands828-func (c *Command) HasRunnableSubCommands() bool {833+func (c *Command) HasNonHelpSubCommands() bool {834 for _, sub := range c.commands {830- if sub.Runnable() {835+ if len(sub.Deprecated) != 0 {836+ continue837+ }838+ if !sub.IsHelpCommand() {839 return true840 }841 }842 return false183 unmodified lines