From af1141d9c1b32138133826cc1a215e4f099f623d Mon Sep 17 00:00:00 2001 From: Nelz Date: Wed, 3 Jul 2019 10:15:25 -0700 Subject: [PATCH] rename to MatchAll --- README.md | 2 +- args.go | 4 ++-- args_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3c445e323b..b002609797 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 c91eb215c6..1b94ab738d 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 4956a2349a..5983de0d32 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 {