@@ -181,17 +181,7 @@ func DefaultShortHelp(c *CommandInfo) string {
181181 }
182182
183183 if len (c .Subcmds ) > 0 {
184- var maxCmdNameLen int
185- for i := range c .Subcmds {
186- if n := len (c .Subcmds [i ].Name ); n > maxCmdNameLen {
187- maxCmdNameLen = n
188- }
189- }
190-
191- u .WriteString ("\n commands:\n " )
192- for i := range c .Subcmds {
193- fmt .Fprintf (& u , " %-*s %s\n " , maxCmdNameLen , c .Subcmds [i ].Name , c .Subcmds [i ].HelpBlurb )
194- }
184+ helpWriteSubcmds (& u , c )
195185 }
196186
197187 return u .String ()
@@ -327,17 +317,7 @@ func DefaultFullHelp(c *CommandInfo) string {
327317 }
328318
329319 if len (c .Subcmds ) > 0 {
330- var maxCmdNameLen int
331- for i := range c .Subcmds {
332- if n := len (c .Subcmds [i ].Name ); n > maxCmdNameLen {
333- maxCmdNameLen = n
334- }
335- }
336-
337- u .WriteString ("\n commands:\n " )
338- for i := range c .Subcmds {
339- fmt .Fprintf (& u , " %-*s %s\n " , maxCmdNameLen , c .Subcmds [i ].Name , c .Subcmds [i ].HelpBlurb )
340- }
320+ helpWriteSubcmds (& u , c )
341321 }
342322
343323 return u .String ()
@@ -379,6 +359,20 @@ func (o *InputInfo) optUsgArgName() string {
379359 return "<arg>"
380360}
381361
362+ func helpWriteSubcmds (u * strings.Builder , c * CommandInfo ) {
363+ var maxCmdNameLen int
364+ for i := range c .Subcmds {
365+ if n := len (c .Subcmds [i ].Name ); n > maxCmdNameLen {
366+ maxCmdNameLen = n
367+ }
368+ }
369+
370+ u .WriteString ("\n commands:\n " )
371+ for i := range c .Subcmds {
372+ fmt .Fprintf (u , " %-*s %s\n " , maxCmdNameLen , c .Subcmds [i ].Name , c .Subcmds [i ].HelpBlurb )
373+ }
374+ }
375+
382376func wrapBlurb (v string , indentLen , lineLen int ) string {
383377 s := wrapText (v , indentLen , lineLen )
384378 return s [indentLen :]
0 commit comments