Skip to content

Commit fce8d8a

Browse files
authored
Expose ValidateRequiredFlags and ValidateFlagGroups (#1760)
1 parent a281c8b commit fce8d8a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

command.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,10 @@ func (c *Command) execute(a []string) (err error) {
862862
c.PreRun(c, argWoFlags)
863863
}
864864

865-
if err := c.validateRequiredFlags(); err != nil {
865+
if err := c.ValidateRequiredFlags(); err != nil {
866866
return err
867867
}
868-
if err := c.validateFlagGroups(); err != nil {
868+
if err := c.ValidateFlagGroups(); err != nil {
869869
return err
870870
}
871871

@@ -1019,7 +1019,8 @@ func (c *Command) ValidateArgs(args []string) error {
10191019
return c.Args(c, args)
10201020
}
10211021

1022-
func (c *Command) validateRequiredFlags() error {
1022+
// ValidateRequiredFlags validates all required flags are present and returns an error otherwise
1023+
func (c *Command) ValidateRequiredFlags() error {
10231024
if c.DisableFlagParsing {
10241025
return nil
10251026
}

flag_groups.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func (c *Command) MarkFlagsMutuallyExclusive(flagNames ...string) {
5959
}
6060
}
6161

62-
// validateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the
62+
// ValidateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the
6363
// first error encountered.
64-
func (c *Command) validateFlagGroups() error {
64+
func (c *Command) ValidateFlagGroups() error {
6565
if c.DisableFlagParsing {
6666
return nil
6767
}

0 commit comments

Comments
 (0)