diff options
| author | brettlangdon <[email protected]> | 2015-11-21 18:59:40 -0500 |
|---|---|---|
| committer | brettlangdon <[email protected]> | 2015-11-21 18:59:40 -0500 |
| commit | d45bd4523c98b9190de5cd7a43ee32087451fe5f (patch) | |
| tree | 3d006d26c56499758ff7a58091e9a66751c02864 /usage.go | |
| parent | 5db9c77fa32bd444360f8376ddfa7bc209813b20 (diff) | |
Display help text for positional arguments
Diffstat (limited to 'usage.go')
| -rw-r--r-- | usage.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -68,11 +68,24 @@ func (p *Parser) WriteHelp(w io.Writer) { p.WriteUsage(w) + // the width of the left column + const colWidth = 25 + // write the list of positionals if len(positionals) > 0 { fmt.Fprint(w, "\npositional arguments:\n") for _, spec := range positionals { - fmt.Fprintf(w, " %s\n", spec.long) + left := " " + spec.long + fmt.Fprint(w, left) + if spec.help != "" { + if len(left)+2 < colWidth { + fmt.Fprint(w, strings.Repeat(" ", colWidth-len(left))) + } else { + fmt.Fprint(w, "\n"+strings.Repeat(" ", colWidth)) + } + fmt.Fprint(w, spec.help) + } + fmt.Fprint(w, "\n") } } |
