diff --git a/README.md b/README.md index 3c445e323..b00260979 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/args.go b/args.go index c91eb215c..1b94ab738 100644 --- a/args.go +++ b/args.go @@ -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 { diff --git a/args_test.go b/args_test.go index 4956a2349..5983de0d3 100644 --- a/args_test.go +++ b/args_test.go @@ -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 {