summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2021-09-18 08:53:02 -0700
committerGitHub <[email protected]>2021-09-18 08:53:02 -0700
commit66cb696e79be30bc979cb003ef8bdecc78266ced (patch)
treeba0b72435521836a0b3653e4494b1fa09e5d1dbc
parentff38a63b36f6b4e60c34ffd0dbf6529d73fa5950 (diff)
parent0f0b4b5c3f9dfab413c3127830b869bc7d4b0e27 (diff)
Merge pull request #164 from evgenv123/evgenv123-patch-1
Update README.md
-rw-r--r--README.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/README.md b/README.md
index 229a9df..dab2996 100644
--- a/README.md
+++ b/README.md
@@ -169,6 +169,17 @@ arg.Foo = "abc"
arg.MustParse(&args)
```
+### Combining command line options, environment variables, and default values
+
+You can combine command line arguments, environment variables, and default values. Command line arguments take precedence over environment variables, which take precedence over default values. This means that we check whether a certain option was provided on the command line, then if not, we check for an environment variable (only if an `env` tag was provided), then if none is found, we check for a `default` tag containing a default value.
+
+```go
+var args struct {
+ Test string `arg:"-t,env:TEST" default:"something"`
+}
+arg.MustParse(&args)
+```
+
### Arguments with multiple values
```go
var args struct {