Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix issue by adding custom replaceAll function and replacing all newlines by newlines+spaces in command usage description
  • Loading branch information
kchugalinskiy committed Aug 17, 2021
1 parent 58d113d commit 11a6082
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs
"indent": indent,
"nindent": nindent,
"trim": strings.TrimSpace,
"replaceAll": strings.ReplaceAll,
}
for key, value := range customFuncs {
funcMap[key] = value
Expand Down
8 changes: 4 additions & 4 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
{{join .Names ", "}}{{"\t"}}{{replaceAll .Usage "\n" "\n "}}{{end}}{{else}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{replaceAll .Usage "\n" "\n "}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
Expand Down Expand Up @@ -66,8 +66,8 @@ DESCRIPTION:
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
{{join .Names ", "}}{{"\t"}}{{replaceAll .Usage "\n" "\n "}}{{end}}{{else}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{replaceAll .Usage "\n" "\n "}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
OPTIONS:
{{range .VisibleFlags}}{{.}}
Expand Down

0 comments on commit 11a6082

Please sign in to comment.