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 d2d2098 commit 6dbf2c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func ShowCommandCompletions(ctx *Context, command string) {
func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs map[string]interface{}) {
funcMap := template.FuncMap{
"join": strings.Join,
"replaceAll": strings.ReplaceAll,
}
for key, value := range customFuncs {
funcMap[key] = value
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
Expand Down

0 comments on commit 6dbf2c0

Please sign in to comment.