cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Added flags groups which are mutually exclusive but required

Open lavafroth opened this issue 2 years ago • 1 comments

This commit adds flag groups which are mutually exclusive but required, as in, at least one of the flags in a group must be supplied.

For example:

rootCmd.Flags().StringVarP(&authToken, "auth-token", "t", "", "Authentication token (required if password is not set)")
rootCmd.Flags().StringVarP(&pw, "password", "p", "", "Password (required if authentication token is not set)")
rootCmd.MarkFlagsMutuallyExclusiveRequired("auth-token", "password")

lavafroth avatar Jul 02 '22 04:07 lavafroth

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 02 '22 04:07 CLAassistant