Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit180cd3e

Browse files
committed
fix: Update cli usage template for cobra feature parity
Fixes#1423Related#1233,#1403
1 parent7bb7c6c commit180cd3e

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

‎cli/root.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,32 @@ func usageTemplate() string {
183183
// more visually appealing.
184184
header:=cliui.Styles.Placeholder
185185

186-
return`{{if .HasExample}}`+header.Render("Get Started:")+`
187-
{{.Example}}
186+
returnheader.Render("Usage:")+`{{if .Runnable}}
187+
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
188+
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
188189
189-
{{end}}{{if .HasAvailableLocalFlags}}`+header.Render("Flags:")+`
190-
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableSubCommands}}
190+
`+header.Render("Aliases:")+`
191+
{{.NameAndAliases}}{{end}}{{if .HasExample}}
191192
192-
`+header.Render("Commands:")+`{{range .Commands}}{{if and .IsAvailableCommand (eq (len .Annotations) 0)}}
193-
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ifnot .HasParent}}
193+
`+header.Render("Get Started:")+`
194+
{{.Example}}{{end}}{{if.HasAvailableSubCommands}}
194195
195-
`+header.Render("WorkspaceCommands:")+`{{range .Commands}}{{if and .IsAvailableCommand (ne (index .Annotations "workspaces") "")}}
196-
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}
196+
`+header.Render("Commands:")+`{{range .Commands}}{{if(or (and .IsAvailableCommand (eq (len .Annotations) 0)) (eq .Name "help"))}}
197+
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if and (not .HasParent) .HasAvailableSubCommands}}
197198
198-
Use "{{.CommandPath}} [command] --help" for more information about a command.
199+
`+header.Render("Workspace Commands:")+`{{range .Commands}}{{if (and .IsAvailableCommand (ne (index .Annotations "workspaces") ""))}}
200+
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
201+
202+
`+header.Render("Flags:")+`
203+
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
204+
205+
`+header.Render("Global Flags:")+`
206+
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
207+
208+
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
209+
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
210+
211+
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
199212
`
200213
}
201214

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp