aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2026-01-13 22:46:25 +0000
committerFelix Hanley <felix@userspace.com.au>2026-01-13 22:46:25 +0000
commit3316d2ebc77cef2c2bd03869063910bd8453d704 (patch)
tree83d45db99a68f7d6e11c16d2cadf31612f2fe892 /flag.go
parent87e4f8cc1cc88929700d0fd01d142816ff3c15c6 (diff)
downloadenvflag-3316d2ebc77cef2c2bd03869063910bd8453d704.tar.gz
envflag-3316d2ebc77cef2c2bd03869063910bd8453d704.tar.bz2
Update docs and examplesHEADmaster
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/flag.go b/flag.go
index faa37d8..bef83d7 100644
--- a/flag.go
+++ b/flag.go
@@ -20,7 +20,7 @@ type UsageUpdaterFunc func(key, usage string) string
type config struct {
prefix string
- getenv func(string) string
+ getenv func(string) string
flagConverter FlagConverterFunc
usageUpdater UsageUpdaterFunc
}
@@ -55,6 +55,12 @@ func UsageUpdater(f UsageUpdaterFunc) Option {
}
// UsagePrefixer prefixes the flag usage with [envvar].
+//
+// Example output:
+//
+// Usage of example:
+// -verbose
+// [VERBOSE] Be verbose
func UsagePrefixer() Option {
return func(cfg *config) {
cfg.usageUpdater = usagePrefixer
@@ -62,6 +68,12 @@ func UsagePrefixer() Option {
}
// UsageSuffixer suffixes the flag usage with [envvar].
+//
+// Example output:
+//
+// Usage of example:
+// -verbose
+// Be verbose [VERBOSE]
func UsageSuffixer() Option {
return func(cfg *config) {
cfg.usageUpdater = usageSuffixer
@@ -88,7 +100,7 @@ func parseFlagSetWithEnv(fs *flag.FlagSet, arguments []string, opts ...Option) e
}
cfg := &config{
flagConverter: flagToEnv(),
- getenv: os.Getenv,
+ getenv: os.Getenv,
}
for _, o := range opts {
o(cfg)