Skip to content
Myr

Merge pull request #152 from eparis/no-newline-after-flags

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

No newline after Flags in usage

authored by Eric Paris · committed by Eric Paris · parents 85bb343, 8af2b2b · Browse files · 2 files+15 added−6 removed
This commit

State

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

Diff stats

2 files+15 added−6 removed

  • other:+15 added−6 removed

2 files+15 added−6 removed

modified:cobra.go+10 added-4 removed
21 unmodified lines
22 "reflect"23 "strconv"24 "strings"25 "text/template"26 "unicode"27)2829var templateFuncs template.FuncMap = template.FuncMap{29 "trim": strings.TrimSpace,30 "rpad": rpad,31 "gt": Gt,32 "eq": Eq,30 "trim": strings.TrimSpace,31 "trimRightSpace": trimRightSpace,32 "rpad": rpad,33 "gt": Gt,34 "eq": Eq,35}3637var initializers []func()38
75 unmodified lines
114 }115 return false116}117118func trimRightSpace(s string) string {119 return strings.TrimRightFunc(s, unicode.IsSpace)120}121122//rpad adds padding to the right of a string123func rpad(s string, padding int) string {124 template := fmt.Sprintf("%%-%ds", padding)125 return fmt.Sprintf(template, s)
9 unmodified lines
modified:command.go+5 added-2 removed
184 unmodified lines
185 return c.parent.UsageFunc()186 } else {187 return func(c *Command) error {188 err := tmpl(c.Out(), c.UsageTemplate(), c)189 if err != nil {190 fmt.Print(err)191 }192 return err193 }194 }195}
69 unmodified lines
265Available Commands:{{range .Commands}}{{if .IsAvailableCommand}}266 {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasLocalFlags}}267268Flags:266{{.LocalFlags.FlagUsages}}{{end}}{{ if .HasInheritedFlags}}269{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{ if .HasInheritedFlags}}270271Global Flags:269{{.InheritedFlags.FlagUsages}}{{end}}{{if .HasHelpSubCommands}}272{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}273274Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}275 {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasSubCommands }}276
839 unmodified lines