diff options
| author | Emmanouil "Manolis" Maragkakis <[email protected]> | 2017-01-23 20:41:12 -0500 |
|---|---|---|
| committer | Emmanouil "Manolis" Maragkakis <[email protected]> | 2017-01-23 20:41:12 -0500 |
| commit | db274311536204025bd248faaa74347707be9d76 (patch) | |
| tree | 9fb9264188c1c93a7340885797956e86dad97075 /usage_test.go | |
| parent | 7c77c70f8528a7b3310820aeec46d56a5be1ba70 (diff) | |
add support for description string
Diffstat (limited to 'usage_test.go')
| -rw-r--r-- | usage_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/usage_test.go b/usage_test.go index e60efdb..29a952c 100644 --- a/usage_test.go +++ b/usage_test.go @@ -129,3 +129,31 @@ options: t.Fail() } } + +type described struct{} + +// Described returns the description for this program +func (described) Description() string { + return "this program does this and that" +} + +func TestUsageWithDescription(t *testing.T) { + expectedHelp := `this program does this and that +usage: example + +options: + --help, -h display this help and exit +` + os.Args[0] = "example" + p, err := NewParser(Config{}, &described{}) + require.NoError(t, err) + + var help bytes.Buffer + p.WriteHelp(&help) + actual := help.String() + t.Logf("Expected:\n%s", expectedHelp) + t.Logf("Actual:\n%s", actual) + if expectedHelp != actual { + t.Fail() + } +} |
