File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,34 @@ func NewCmd(p *print.Printer) *cobra.Command {
8888 },
8989 }
9090 configureFlags (cmd )
91+ cmd .SetHelpTemplate ( // Slightly modified help template to merge the command level Flags and Global Flags in a single section
92+ `Usage:{{if .Runnable}}
93+ {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
94+ {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
95+
96+ Aliases:
97+ {{.NameAndAliases}}{{end}}{{if .HasExample}}
98+
99+ Examples:
100+ {{.Example}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
101+
102+ Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
103+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
104+
105+ {{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
106+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
107+
108+ Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
109+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
110+
111+ Flags:
112+ {{.Flags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
113+
114+ Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
115+ {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
116+
117+ Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
118+ ` )
91119 return cmd
92120}
93121
You can’t perform that action at this time.
0 commit comments