code: func EnsureFlagsValid(cmd *cobra.Command, generators map[string]Generator, generatorInUse string) error {
  	AnnotateFlags(cmd, generators)
  
  	allErrs := []error{}
  	cmd.Flags().VisitAll(func(flag *pflag.Flag) {
  		// If the flag hasn't changed, don't validate it.
  		if !flag.Changed {
  			return
  		}
  		// Look into the flag annotations for the generators that can use it.
  		if annotations := flag.Annotations["generator"]; len(annotations) > 0 {
  			annotationMap := map[string]struct{}{}
  			for _, ann := range annotations {
  				annotationMap[ann] = struct{}{}
  			}
  			// If the current generator is not annotated, then this flag shouldn't
  			// be used with it.
  			if _, found := annotationMap[generatorInUse]; !found {
  				allErrs = append(allErrs, fmt.Errorf("cannot use --%s with --generator=%s", flag.Name, generatorInUse))
  			}
  		}
  	})
  	return utilerrors.NewAggregate(allErrs)
  }
docs: // EnsureFlagsValid ensures that no invalid flags are being used against a