summaryrefslogtreecommitdiff
path: root/usage_test.go
diff options
context:
space:
mode:
authorAndrew Morozko <[email protected]>2020-12-20 03:51:33 +0300
committerAndrew Morozko <[email protected]>2020-12-20 03:51:33 +0300
commit438a91dba1e3f7a9263f5408899eeeb12d8453ed (patch)
tree90a11091275809fcbe2d6f449471dfa2bab453f4 /usage_test.go
parent04c3fdbd8019af78797e714ac5070d7056e71f57 (diff)
Skip right column if the left is empty
Diffstat (limited to 'usage_test.go')
-rw-r--r--usage_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/usage_test.go b/usage_test.go
index de40ebd..8e28dc5 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -328,3 +328,23 @@ Options:
p.WriteHelp(&help)
assert.Equal(t, expectedHelp, help.String())
}
+
+func TestUsageWithEnvOptions(t *testing.T) {
+ expectedHelp := `Usage: example [-s SHORT]
+
+Options:
+ -s SHORT [env: SHORT]
+ --help, -h display this help and exit
+`
+ var args struct {
+ Short string `arg:"--,-s,env"`
+ EnvOnly string `arg:"--,env"`
+ EnvOnlyOverriden string `arg:"--,env:CUSTOM"`
+ }
+
+ p, err := NewParser(Config{Program: "example"}, &args)
+ assert.NoError(t, err)
+ var help bytes.Buffer
+ p.WriteHelp(&help)
+ assert.Equal(t, expectedHelp, help.String())
+}