Skip to content

Commit

Permalink
Expose ValidateRequiredFlags and ValidateFlagGroups (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
skeetwu authored Sep 27, 2022
1 parent a281c8b commit fce8d8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,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
}

Expand Down Expand Up @@ -1019,7 +1019,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
}
Expand Down
4 changes: 2 additions & 2 deletions flag_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,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
}
Expand Down

0 comments on commit fce8d8a

Please sign in to comment.