summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-01-18 08:19:10 -0800
committerAlex Flint <[email protected]>2016-01-18 08:19:10 -0800
commit77be03b90761b82eba21944a2486758973f110e9 (patch)
tree729d524a2fff4a5e9dae5d0084b90619ca3a98da /usage.go
parentd97f8fd931505639da3aa68847629e937de41ef9 (diff)
parentd45bd4523c98b9190de5cd7a43ee32087451fe5f (diff)
resolve merge
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/usage.go b/usage.go
index 23f7aa5..65f7c2d 100644
--- a/usage.go
+++ b/usage.go
@@ -69,11 +69,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")
}
}