summaryrefslogtreecommitdiff
path: root/usage_test.go
diff options
context:
space:
mode:
authorEmmanouil "Manolis" Maragkakis <[email protected]>2017-01-23 20:41:12 -0500
committerEmmanouil "Manolis" Maragkakis <[email protected]>2017-01-23 20:41:12 -0500
commitdb274311536204025bd248faaa74347707be9d76 (patch)
tree9fb9264188c1c93a7340885797956e86dad97075 /usage_test.go
parent7c77c70f8528a7b3310820aeec46d56a5be1ba70 (diff)
add support for description string
Diffstat (limited to 'usage_test.go')
-rw-r--r--usage_test.go28
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()
+ }
+}