Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Multiple Required/Persistent Flags #2110

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SeanPino
Copy link

@SeanPino SeanPino commented Feb 20, 2024

This adds the ability to call MarkFlagsRequired and MarkPersistentFlagsRequired for n flags instead of one by one.

Flags:

rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.Flags().StringVarP(&Failover, "failoverRegion", "f", "", "AWS failover region (required)")
rootCmd.MarkFlagsRequired("region", "failoverRegion")

Persistent Flags:

rootCmd.PersistentFlags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
rootCmd.PersistentFlags().StringVarP(&Failover, "failoverRegion", "f", "", "AWS failover region (required)")
rootCmd.MarkPersistentFlagsRequired("region", "failoverRegion")

This is similar to grouping but doesn't have the drawback of needing any members of the group to be set just all are required.

@CLAassistant
Copy link

CLAassistant commented Feb 20, 2024

CLA assistant check
All committers have signed the CLA.

@SeanPino SeanPino marked this pull request as ready for review February 20, 2024 16:04
@SeanPino SeanPino changed the title Multiple Required/Persistent Flags feat: Multiple Required/Persistent Flags Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants