Skip to content
Myr

fix usage template conditional

Before adoption: this commit came in with the history the project adopted, so no landing records it.

I wrote https://github.com/eparis/readable-golang-template which converts golang templates into something structured around the conditionals. Obviously you can't just USE the output, but you can SEE the problems. In this case the output shows something like: {{if .HasParent}} {{if and (gt .Commands 0) (gt .Parent.Commands 1) }} Additional help topics: {{if gt .Commands 0 }} {{range .Commands}} {{if not .Runnable}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}} {{end}} {{end}} {{end}} {{if gt .Parent.Commands 1 }} {{range .Parent.Commands}} {{if .Runnable}} {{if not (eq .Name $cmd.Name) }} {{end}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}} {{end}} {{end}} {{end}} {{end}} {{end}} We have a completely unused "{{if not (eq .Name $cmd.Name) }}" Move the {{end}} after the {{rpad...}}

authored by Eric Paris · committed by Eric Paris · parent 384c059 · Browse files · 1 file+2 added−2 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+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:command.go+2 added-2 removed
230 unmodified lines
231{{ if .HasLocalFlags}}Flags:232{{.LocalFlags.FlagUsages}}{{end}}233{{ if .HasInheritedFlags}}Global Flags:234{{.InheritedFlags.FlagUsages}}{{end}}{{if .HasParent}}{{if and (gt .Commands 0) (gt .Parent.Commands 1) }}235Additional help topics: {{if gt .Commands 0 }}{{range .Commands}}{{if not .Runnable}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if gt .Parent.Commands 1 }}{{range .Parent.Commands}}{{if .Runnable}}{{if not (eq .Name $cmd.Name) }}{{end}}236 {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{end}}235Additional help topics: {{if gt .Commands 0 }}{{range .Commands}}{{if not .Runnable}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if gt .Parent.Commands 1 }}{{range .Parent.Commands}}{{if .Runnable}}{{if not (eq .Name $cmd.Name) }}236 {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}237{{end}}{{ if .HasSubCommands }}238Use "{{.Root.Name}} help [command]" for more information about a command.239{{end}}`240 }
718 unmodified lines