Improve readability of usage text

Separates flag and description by a newline to make it easier to read
the flags with long descriptions.
This commit is contained in:
Tobias Schmidt 2015-04-08 17:02:22 -04:00
parent 2d7d1a34b6
commit 35a44509fb
1 changed files with 4 additions and 4 deletions

View File

@ -317,15 +317,15 @@ func usage() {
} }
for _, fl := range groups[groupName] { for _, fl := range groups[groupName] {
format := " -%s=%s: " format := " -%s=%s"
if strings.Contains(fl.DefValue, " ") || fl.DefValue == "" { if strings.Contains(fl.DefValue, " ") || fl.DefValue == "" {
format = " -%s=%q: " format = " -%s=%q"
} }
flagUsage := fmt.Sprintf(format, fl.Name, fl.DefValue) flagUsage := fmt.Sprintf(format+lineSep, fl.Name, fl.DefValue)
// Format the usage text to not exceed maxLineLength characters per line. // Format the usage text to not exceed maxLineLength characters per line.
words := strings.SplitAfter(fl.Usage, " ") words := strings.SplitAfter(fl.Usage, " ")
lineLength := len(flagUsage) lineLength := len(lineSep) - 1
for _, w := range words { for _, w := range words {
if lineLength+len(w) > maxLineLength { if lineLength+len(w) > maxLineLength {
flagUsage += lineSep flagUsage += lineSep