diff options
| author | Andrew Morozko <[email protected]> | 2020-12-20 02:54:03 +0300 |
|---|---|---|
| committer | Andrew Morozko <[email protected]> | 2020-12-20 02:54:03 +0300 |
| commit | faebd3e0f24333a5777102db081a844fdaf7b07b (patch) | |
| tree | 3fc7fc1b29a7c592d16d82d38ff82a991c203b0c /usage_test.go | |
| parent | b91c03d2c6c9e6429f3947f6b6e83321a56aa0f2 (diff) | |
Optional long arguments
Diffstat (limited to 'usage_test.go')
| -rw-r--r-- | usage_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usage_test.go b/usage_test.go index 5d379a1..de40ebd 100644 --- a/usage_test.go +++ b/usage_test.go @@ -309,3 +309,22 @@ Global options: p.WriteHelp(&help) assert.Equal(t, expectedHelp, help.String()) } + +func TestUsageWithOptionalLongNames(t *testing.T) { + expectedHelp := `Usage: example [-a PLACEHOLDER] -b SHORTONLY2 + +Options: + -a PLACEHOLDER some help [default: some val] + -b SHORTONLY2 some help2 + --help, -h display this help and exit +` + var args struct { + ShortOnly string `arg:"-a,--" help:"some help" default:"some val" placeholder:"PLACEHOLDER"` + ShortOnly2 string `arg:"-b,--,required" help:"some help2"` + } + p, err := NewParser(Config{Program: "example"}, &args) + assert.NoError(t, err) + var help bytes.Buffer + p.WriteHelp(&help) + assert.Equal(t, expectedHelp, help.String()) +} |
