Merge pull request #7 from brettlangdon/dev/trailing.whitespace.sqwished

Remove excess trailing whitespace from Usage generation
This commit is contained in:
Alex Flint 2015-11-09 09:54:04 -08:00
commit a6c77a413a
2 changed files with 7 additions and 5 deletions

View File

@ -31,6 +31,8 @@ func (p *Parser) WriteUsage(w io.Writer) {
// write the option component of the usage message // write the option component of the usage message
for _, spec := range options { for _, spec := range options {
// prefix with a space
fmt.Fprint(w, " ")
if !spec.required { if !spec.required {
fmt.Fprint(w, "[") fmt.Fprint(w, "[")
} }
@ -38,18 +40,18 @@ func (p *Parser) WriteUsage(w io.Writer) {
if !spec.required { if !spec.required {
fmt.Fprint(w, "]") fmt.Fprint(w, "]")
} }
fmt.Fprint(w, " ")
} }
// write the positional component of the usage message // write the positional component of the usage message
for _, spec := range positionals { for _, spec := range positionals {
// prefix with a space
fmt.Fprint(w, " ")
up := strings.ToUpper(spec.long) up := strings.ToUpper(spec.long)
if spec.multiple { if spec.multiple {
fmt.Fprintf(w, "[%s [%s ...]]", up, up) fmt.Fprintf(w, "[%s [%s ...]]", up, up)
} else { } else {
fmt.Fprint(w, up) fmt.Fprint(w, up)
} }
fmt.Fprint(w, " ")
} }
fmt.Fprint(w, "\n") fmt.Fprint(w, "\n")
} }