diff options
| author | Alex Flint <[email protected]> | 2022-10-29 15:19:23 -0400 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2022-10-29 15:19:23 -0400 |
| commit | 3d95a706a6a1cc80d62f403778c5d160698003b0 (patch) | |
| tree | b451fc515320dc6721dacc601b799266a8f78c3b /usage_test.go | |
| parent | d949871b676ed52669c17c2070dfb770b6ce28da (diff) | |
| parent | dbc2ba5d0c9a6a439d1f825f8c299fb276bbc911 (diff) | |
Merge remote-tracking branch 'origin/master' into default-value-issue
Diffstat (limited to 'usage_test.go')
| -rw-r--r-- | usage_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/usage_test.go b/usage_test.go index 8fb32c8..be5894a 100644 --- a/usage_test.go +++ b/usage_test.go @@ -284,6 +284,37 @@ Options: assert.Equal(t, expectedUsage, strings.TrimSpace(usage.String())) } +type epilogued struct{} + +// Epilogued returns the epilogue for this program +func (epilogued) Epilogue() string { + return "For more information visit github.com/alexflint/go-arg" +} + +func TestUsageWithEpilogue(t *testing.T) { + expectedUsage := "Usage: example" + + expectedHelp := ` +Usage: example + +Options: + --help, -h display this help and exit + +For more information visit github.com/alexflint/go-arg +` + os.Args[0] = "example" + p, err := NewParser(Config{}, &epilogued{}) + require.NoError(t, err) + + var help bytes.Buffer + p.WriteHelp(&help) + assert.Equal(t, expectedHelp[1:], help.String()) + + var usage bytes.Buffer + p.WriteUsage(&usage) + assert.Equal(t, expectedUsage, strings.TrimSpace(usage.String())) +} + func TestUsageForRequiredPositionals(t *testing.T) { expectedUsage := "Usage: example REQUIRED1 REQUIRED2\n" var args struct { |
