Skip to content

Commit

Permalink
rename to MatchAll
Browse files Browse the repository at this point in the history
  • Loading branch information
nelz9999 committed Sep 6, 2019
1 parent 3c9dde6 commit af1141d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -399,7 +399,7 @@ The following validators are built in:
- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.
- `ExactValidArgs(int)` - the command will report an error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command`
- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.
- `ComposedArgs(pargs ...PositionalArgs)` - enables combining existing checks with arbitrary other checks (e.g. you want to check the ExactArgs length along with other qualities).
- `MatchAll(pargs ...PositionalArgs)` - enables combining existing checks with arbitrary other checks (e.g. you want to check the ExactArgs length along with other qualities).

An example of setting the custom validator:

Expand Down
4 changes: 2 additions & 2 deletions args.go
Expand Up @@ -100,8 +100,8 @@ func RangeArgs(min int, max int) PositionalArgs {
}
}

// ComposedArgs allows combining several PositionalArgs to work in concert.
func ComposedArgs(pargs ...PositionalArgs) PositionalArgs {
// MatchAll allows combining several PositionalArgs to work in concert.
func MatchAll(pargs ...PositionalArgs) PositionalArgs {
return func(cmd *Command, args []string) error {
for _, parg := range pargs {
if err := parg(cmd, args); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions args_test.go
Expand Up @@ -287,10 +287,10 @@ func TestChildTakesArgs(t *testing.T) {
}
}

func TestComposedArgs(t *testing.T) {
func TestMatchAll(t *testing.T) {
// Somewhat contrived example check that ensures there are exactly 3
// arguments, and each argument is exactly 2 bytes long.
pargs := ComposedArgs(
pargs := MatchAll(
ExactArgs(3),
func(cmd *Command, args []string) error {
for _, arg := range args {
Expand Down

0 comments on commit af1141d

Please sign in to comment.