From 87d22b8fdbc20894446e96b436db871c4b1ff6f7 Mon Sep 17 00:00:00 2001 From: umarcor Date: Thu, 24 Feb 2022 21:57:31 +0100 Subject: [PATCH] undefined or nil Args default to ArbitraryArgs --- command.go | 2 +- user_guide.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/command.go b/command.go index ee5365bcb..9e994c7e9 100644 --- a/command.go +++ b/command.go @@ -1008,7 +1008,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { func (c *Command) ValidateArgs(args []string) error { if c.Args == nil { - return nil + return ArbitraryArgs(c, args) } return c.Args(c, args) } diff --git a/user_guide.md b/user_guide.md index cbf9a897b..f984f03fa 100644 --- a/user_guide.md +++ b/user_guide.md @@ -302,8 +302,8 @@ rootCmd.MarkPersistentFlagRequired("region") ## Positional and Custom Arguments -Validation of positional arguments can be specified using the `Args` field -of `Command`. +Validation of positional arguments can be specified using the `Args` field of `Command`. +If `Args` is undefined or `nil`, it defaults to `ArbitraryArgs`. The following validators are built in: