Merge pull request #164 from evgenv123/evgenv123-patch-1

Update README.md
This commit is contained in:
Alex Flint 2021-09-18 08:53:02 -07:00 committed by GitHub
commit 66cb696e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -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 {