add an example of parsing into a map to the readme
This commit is contained in:
parent
0100c0a411
commit
91214e01ea
15
README.md
15
README.md
|
@ -191,6 +191,7 @@ var args struct {
|
||||||
Files []string `arg:"-f,separate"`
|
Files []string `arg:"-f,separate"`
|
||||||
Databases []string `arg:"positional"`
|
Databases []string `arg:"positional"`
|
||||||
}
|
}
|
||||||
|
arg.MustParse(&args)
|
||||||
```
|
```
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -200,6 +201,20 @@ Files [file1 file2 file3]
|
||||||
Databases [db1 db2 db3]
|
Databases [db1 db2 db3]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Arguments with keys and values
|
||||||
|
```go
|
||||||
|
var args struct {
|
||||||
|
UserIDs map[string]int
|
||||||
|
}
|
||||||
|
arg.MustParse(&args)
|
||||||
|
fmt.Println(args.UserIDs)
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./example --userids john=123 mary=456
|
||||||
|
map[john:123 mary:456]
|
||||||
|
```
|
||||||
|
|
||||||
### Custom validation
|
### Custom validation
|
||||||
```go
|
```go
|
||||||
var args struct {
|
var args struct {
|
||||||
|
|
Loading…
Reference in New Issue