diff options
| author | Pablo Diaz <[email protected]> | 2022-05-20 17:35:02 +0200 |
|---|---|---|
| committer | Ilja Neumann <[email protected]> | 2023-06-03 02:39:42 +0200 |
| commit | 0280e6e5911d4198f69eae9c876722fdf6149b89 (patch) | |
| tree | 2d97782aae35ffdab788b8cacfcfaa1fd4b056d2 /example_test.go | |
| parent | e25b4707a7d6c63ff6910c1e1bcb416cb8debfb2 (diff) | |
ignores short and long parameters
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 5272393..acfacad 100644 --- a/example_test.go +++ b/example_test.go @@ -496,3 +496,19 @@ func Example_allSupportedTypes() { // output: } + +func Example_envVarOnly() { + os.Args = split("./example") + _ = os.Setenv("NUM_WORKERS", "my_key") + + defer os.Unsetenv("NUM_WORKERS") + + var args struct { + AuthKey string `arg:"-,--,env:NUM_WORKERS"` + } + + MustParse(&args) + + fmt.Println(args.AuthKey) + // output: my_key +} |
