summaryrefslogtreecommitdiff
path: root/usage_test.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_test.go
parentd97f8fd931505639da3aa68847629e937de41ef9 (diff)
parentd45bd4523c98b9190de5cd7a43ee32087451fe5f (diff)
resolve merge
Diffstat (limited to 'usage_test.go')
-rw-r--r--usage_test.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/usage_test.go b/usage_test.go
index 07edc18..2375e81 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -16,7 +16,7 @@ func TestWriteUsage(t *testing.T) {
positional arguments:
input
- output
+ output list of outputs
options:
--name NAME name to use [default: Foo Bar]
@@ -30,7 +30,7 @@ options:
`
var args struct {
Input string `arg:"positional"`
- Output []string `arg:"positional"`
+ Output []string `arg:"positional,help:list of outputs"`
Name string `arg:"help:name to use"`
Value int `arg:"help:secret value"`
Verbose bool `arg:"-v,help:verbosity level"`
@@ -53,3 +53,26 @@ options:
p.WriteHelp(&help)
assert.Equal(t, expectedHelp, help.String())
}
+
+func TestUsageLongPositionalWithHelp(t *testing.T) {
+ expectedHelp := `usage: example VERYLONGPOSITIONALWITHHELP
+
+positional arguments:
+ verylongpositionalwithhelp
+ this positional argument is very long
+
+options:
+ --help, -h display this help and exit
+`
+ var args struct {
+ VeryLongPositionalWithHelp string `arg:"positional,help:this positional argument is very long"`
+ }
+
+ p, err := NewParser(&args)
+ require.NoError(t, err)
+
+ os.Args[0] = "example"
+ var help bytes.Buffer
+ p.WriteHelp(&help)
+ assert.Equal(t, expectedHelp, help.String())
+}