cobra
cobra copied to clipboard
Added flags groups which are mutually exclusive but required
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")