@@ -66,30 +66,29 @@ func DefaultShortHelp(c *CommandInfo) string {
6666 desc += " (required)"
6767 }
6868 if o .HasStrDefault {
69- desc += fmt . Sprintf ( " (default: %v)" , o .StrDefault )
69+ desc += " (default: " + o .StrDefault + ")"
7070 }
7171 if o .EnvVar != "" {
7272 desc += " [$" + o .EnvVar + "]"
7373 }
74- var namesAndVal string
75- {
74+
75+ content := " "
76+ if o .NameShort != 0 {
77+ content += "-" + string (o .NameShort )
78+ }
79+ if o .NameLong != "" {
7680 if o .NameShort != 0 {
77- namesAndVal += "-" + string (o .NameShort )
78- }
79- if o .NameLong != "" {
80- if o .NameShort != 0 {
81- namesAndVal += ", "
82- }
83- namesAndVal += "--" + o .NameLong
84- }
85- if an := o .optUsgArgName (); an != "" {
86- namesAndVal += " " + an
81+ content += ", "
8782 }
83+ content += "--" + o .NameLong
84+ }
85+ if an := o .optUsgArgName (); an != "" {
86+ content += " " + an
8887 }
89- content := " " + namesAndVal
90- content += "\n " + strings .Repeat (" " , 6 )
91- content += wrapBlurb (desc , 6 , helpMsgTextWidth )
88+
9289 u .WriteString (content )
90+ u .WriteString ("\n " + strings .Repeat (" " , 6 ))
91+ u .WriteString (wrapBlurb (desc , 6 , helpMsgTextWidth ))
9392 u .WriteByte ('\n' )
9493 }
9594 } else {
@@ -99,14 +98,15 @@ func DefaultShortHelp(c *CommandInfo) string {
9998 desc += " (required)"
10099 }
101100 if o .HasStrDefault {
102- desc += fmt . Sprintf ( " (default: %v)" , o .StrDefault )
101+ desc += " (default: " + o .StrDefault + ")"
103102 }
104103 if o .EnvVar != "" {
105104 desc += " [$" + o .EnvVar + "]"
106105 }
107- content := fmt .Sprintf (" %-*s " , optNameColWidth , optLeftPaddedNames [i ])
108- content += wrapBlurb (desc , len (content ), helpMsgTextWidth )
109- u .WriteString (content )
106+ rightPadding := strings .Repeat (" " , (optNameColWidth - len (optLeftPaddedNames [i ]))+ 3 )
107+ paddedNameAndVal := " " + optLeftPaddedNames [i ] + rightPadding
108+ u .WriteString (paddedNameAndVal )
109+ u .WriteString (wrapBlurb (desc , len (paddedNameAndVal ), helpMsgTextWidth ))
110110 u .WriteByte ('\n' )
111111 }
112112 }
@@ -137,20 +137,21 @@ func DefaultShortHelp(c *CommandInfo) string {
137137 desc += " (required)"
138138 }
139139 if a .HasStrDefault {
140- desc += fmt . Sprintf ( " (default: %v)" , a .StrDefault )
140+ desc += " (default: " + a .StrDefault + ")"
141141 }
142142 if a .EnvVar != "" {
143143 desc += " [$" + a .EnvVar + "]"
144144 }
145145
146- var content string
147146 if argNameColWidth > helpShortMsgMaxFirstColLen {
148147 u .WriteString (" " + argNames [i ])
149148 u .WriteString ("\n " + strings .Repeat (" " , 5 ))
150149 u .WriteString (wrapBlurb (desc , 5 , helpMsgTextWidth ))
151150 } else {
152- fmt .Fprintf (& u , " %-*s " , argNameColWidth , argNames [i ])
153- u .WriteString (wrapBlurb (desc , len (content )+ 3 , helpMsgTextWidth ))
151+ rightPadding := strings .Repeat (" " , argNameColWidth - len (argNames [i ])+ 3 )
152+ paddedNameCol := " " + argNames [i ] + rightPadding
153+ u .WriteString (paddedNameCol )
154+ u .WriteString (wrapBlurb (desc , len (paddedNameCol ), helpMsgTextWidth ))
154155 }
155156 u .WriteByte ('\n' )
156157 }
@@ -192,7 +193,7 @@ func DefaultFullHelp(c *CommandInfo) string {
192193 for i , o := range opts {
193194 var extra string
194195 if o .HasStrDefault {
195- extra += fmt . Sprintf ( "\n [default: %v]" , o .StrDefault )
196+ extra += "\n [default: " + o .StrDefault + "]"
196197 }
197198 if o .EnvVar != "" {
198199 extra += "\n [env: " + o .EnvVar + "]"
@@ -237,7 +238,7 @@ func DefaultFullHelp(c *CommandInfo) string {
237238 for i , a := range c .Args {
238239 var extra string
239240 if a .HasStrDefault {
240- extra += fmt . Sprintf ( "\n [default: %v]" , a .StrDefault )
241+ extra += "\n [default: " + a .StrDefault + "]"
241242 }
242243 if a .EnvVar != "" {
243244 extra += "\n [env: " + a .EnvVar + "]"
0 commit comments