Update README.md

Hi! As a first-time user of your great package I got a little bit confused on using command line args and env vars together, so it took me some time to make testing and I propose to save this time for other people by adding relevant edits to README.md
This commit is contained in:
evgenv123 2021-09-18 22:23:26 +07:00 committed by GitHub
parent ff38a63b36
commit b157e8d10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -158,6 +158,19 @@ var args struct {
arg.MustParse(&args)
```
### Priority
You can use both command line arguments and environmental variables at the same time.
The priority is as follows: <b>command line arguments</b> -> if empty we check <b>environmental variables</b> -> and then we use <b>default values</b>
```go
var args struct {
Command string `arg:"-c,env:COMMAND" help:"Command to execute" default:"remove"`
File string `arg:"-f,env:FILE_NAME"`
}
arg.MustParse(&args)
```
### Default values (before v1.2)
```go