diff options
| author | Alex Flint <[email protected]> | 2021-01-31 19:15:49 -0800 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-01-31 19:15:49 -0800 |
| commit | 788c166025870bc4653adb5986d03f99c1d14af2 (patch) | |
| tree | 7b15159d3bd8f0fd95478111ea15170ecab313e3 /usage_test.go | |
| parent | 438a91dba1e3f7a9263f5408899eeeb12d8453ed (diff) | |
test that short-only options are printed first in the help message
Diffstat (limited to 'usage_test.go')
| -rw-r--r-- | usage_test.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usage_test.go b/usage_test.go index 8e28dc5..6dee402 100644 --- a/usage_test.go +++ b/usage_test.go @@ -310,7 +310,7 @@ Global options: assert.Equal(t, expectedHelp, help.String()) } -func TestUsageWithOptionalLongNames(t *testing.T) { +func TestUsageWithoutLongNames(t *testing.T) { expectedHelp := `Usage: example [-a PLACEHOLDER] -b SHORTONLY2 Options: @@ -329,6 +329,25 @@ Options: assert.Equal(t, expectedHelp, help.String()) } +func TestUsageWithShortFirst(t *testing.T) { + expectedHelp := `Usage: example [-c CAT] [--dog DOG] + +Options: + -c CAT + --dog DOG + --help, -h display this help and exit +` + var args struct { + Dog string + Cat string `arg:"-c,--"` + } + p, err := NewParser(Config{Program: "example"}, &args) + assert.NoError(t, err) + var help bytes.Buffer + p.WriteHelp(&help) + assert.Equal(t, expectedHelp, help.String()) +} + func TestUsageWithEnvOptions(t *testing.T) { expectedHelp := `Usage: example [-s SHORT] |
