diff options
| author | Alex Flint <[email protected]> | 2024-06-30 10:31:46 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-30 10:31:46 -0400 |
| commit | 56ee7c97acb3a23c0732440ee9d6157e7011c6b2 (patch) | |
| tree | cd71f8497cd2e4b5cc101e9e6391bf691ed09f80 | |
| parent | 177b84441e5eb5667ef51f93bbd8e34eecc5c0a8 (diff) | |
| parent | 84ddf1d244f4bbe299f082e1c880c34831f49c57 (diff) | |
Merge pull request #237 from purpleidea/feat/env-docs
add an example for environment vars with arg names
| -rw-r--r-- | README.md | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -120,6 +120,23 @@ $ WORKERS='1,99' ./example Workers: [1 99] ``` +You can also have an environment variable that doesn't match the arg name: + +```go +var args struct { + Workers int `arg:"--count,env:NUM_WORKERS"` +} +arg.MustParse(&args) +fmt.Println("Workers:", args.Workers) +``` + +``` +$ NUM_WORKERS=6 ./example +Workers: 6 +$ NUM_WORKERS=6 ./example --count 4 +Workers: 4 +``` + ### Usage strings ```go var args struct { |
