Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube authored Jan 29, 2023
1 parent ad02566 commit fba1a23
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ rootCmd.Flag("agentlib").OptargDelimiter = ':'
### Nargs

**Experimental** Support for flags consuming multiple arguments.
Use with `Slice` and `Array` flag types.
> Use with `Slice` and `Array` flag types.
```go
rootCmd.Flags().StringSlice("nargs-any", []string{}, "Nargs")
rootCmd.Flags().StringSlice("nargs-two", []string{}, "Nargs")
rootCmd.Flags().StringSlice("nargs-any", []string{}, "Nargs")
rootCmd.Flags().StringSlice("nargs-two", []string{}, "Nargs")

rootCmd.Flag("nargs-any").Nargs = -1 // consumes any argument until one starts with `-`
rootCmd.Flag("nargs-two").Nargs = 2 // consumes exactly 2 arguments
```
rootCmd.Flag("nargs-any").Nargs = -1 // consumes any argument until one starts with `-`
rootCmd.Flag("nargs-two").Nargs = 2 // consumes exactly 2 arguments
```

0 comments on commit fba1a23

Please sign in to comment.