From d45bd4523c98b9190de5cd7a43ee32087451fe5f Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sat, 21 Nov 2015 18:59:40 -0500 Subject: Display help text for positional arguments --- usage_test.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'usage_test.go') diff --git a/usage_test.go b/usage_test.go index 5a9199c..4a56e6e 100644 --- a/usage_test.go +++ b/usage_test.go @@ -16,7 +16,7 @@ func TestWriteUsage(t *testing.T) { positional arguments: input - output + output positional output options: --verbose, -v verbosity level @@ -27,7 +27,7 @@ options: ` var args struct { Input string `arg:"positional"` - Output []string `arg:"positional"` + Output []string `arg:"positional,help:positional output"` Verbose bool `arg:"-v,help:verbosity level"` Dataset string `arg:"help:dataset to use"` Optimize int `arg:"-O,help:optimization level"` @@ -45,3 +45,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()) +} -- cgit v1.2.3