Add ability to mark flags as required or exclusive as a group (#1654)
This change adds two features for dealing with flags: - requiring flags be provided as a group (or not at all) - requiring flags be mutually exclusive of each other By utilizing the flag annotations we can mark which flag groups a flag is a part of and during the parsing process we track which ones we have seen or not. A flag may be a part of multiple groups. The list of flags and the type of group (required together or exclusive) make it a unique group. Signed-off-by: John Schnake <jschnake@vmware.com>
This commit is contained in:
@ -863,6 +863,10 @@ func (c *Command) execute(a []string) (err error) {
|
||||
if err := c.validateRequiredFlags(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.validateFlagGroups(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.RunE != nil {
|
||||
if err := c.RunE(c, argWoFlags); err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user