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:
parent
ff38a63b36
commit
b157e8d10a
13
README.md
13
README.md
|
@ -158,6 +158,19 @@ var args struct {
|
||||||
arg.MustParse(&args)
|
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)
|
### Default values (before v1.2)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
Loading…
Reference in New Issue