mirror of
https://github.com/spf13/cobra
synced 2025-05-05 04:47:22 +00:00
expose ValidateRequiredFlags and ValidateFlagGroups
This commit is contained in:
parent
a0aadc68eb
commit
6f8a0a30e9
2 changed files with 6 additions and 5 deletions
|
@ -861,10 +861,10 @@ func (c *Command) execute(a []string) (err error) {
|
|||
c.PreRun(c, argWoFlags)
|
||||
}
|
||||
|
||||
if err := c.validateRequiredFlags(); err != nil {
|
||||
if err := c.ValidateRequiredFlags(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.validateFlagGroups(); err != nil {
|
||||
if err := c.ValidateFlagGroups(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1018,8 @@ func (c *Command) ValidateArgs(args []string) error {
|
|||
return c.Args(c, args)
|
||||
}
|
||||
|
||||
func (c *Command) validateRequiredFlags() error {
|
||||
// ValidateRequiredFlags validates all required flags are present and returns an error otherwise
|
||||
func (c *Command) ValidateRequiredFlags() error {
|
||||
if c.DisableFlagParsing {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -58,9 +58,9 @@ func (c *Command) MarkFlagsMutuallyExclusive(flagNames ...string) {
|
|||
}
|
||||
}
|
||||
|
||||
// validateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the
|
||||
// ValidateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the
|
||||
// first error encountered.
|
||||
func (c *Command) validateFlagGroups() error {
|
||||
func (c *Command) ValidateFlagGroups() error {
|
||||
if c.DisableFlagParsing {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue