// Flag defines a new flag with the given long name and help.
963563
func (f *flagGroup) Flag(name, help string) *FlagClause {
	flag := newFlag(name, help)
	f.long[name] = flag
	f.flagOrder = append(f.flagOrder, flag)
	return flag
}
181811
func (m *Message) Flag(flag string) bool {
	if len(m.Attributes) > 0 {
		return m.Attributes.Flag(flag)
	}
	return false
}
516548
func (c *Command) persistentFlag(name string) (flag *flag.Flag) {
	if c.HasPersistentFlags() {
		flag = c.PersistentFlags().Lookup(name)
	}

	if flag == nil {
		c.updateParentsPflags()
		flag = c.parentsPflags.Lookup(name)
	}
	return
}
568173
func (f FlagInfo) BindStringFlag(flags *pflag.FlagSet, target *string) {
	// you can't register a flag without a long name
	if len(f.LongName) > 0 {
		flags.StringVarP(target, f.LongName, f.ShortName, f.Default, f.Description)
	}
}
375015
func Flags(flags ...cli.Flag) Option {
	return func(o *Options) {
		o.Flags = append(o.Flags, flags...)
	}
}
408974
func (m *Media) Flag(f string) bool {
	return m.Attributes.Flag(f)
}
1356944
func (m *Meta) defaultFlagSet(n string) *flag.FlagSet {
	f := flag.NewFlagSet(n, flag.ContinueOnError)

	// Create an io.Writer that writes to our Ui properly for errors.
	// This is kind of a hack, but it does the job. Basically: create
	// a pipe, use a scanner to break it into lines, and output each line
	// to the UI. Do this forever.
	errR, errW := io.Pipe()
	errScanner := bufio.NewScanner(errR)
	go func() {
		// This only needs to be alive long enough to write the help info if
		// there is a flag error. Kill the scanner after a short duriation to
		// prevent these from accumulating during tests, and cluttering up the
		// stack traces.
		time.AfterFunc(2*time.Second, func() {
			errW.Close()
		})
		for errScanner.Scan() {
			m.Ui.Error(errScanner.Text())
		}
	}()
	f.SetOutput(errW)

	// Set the default Usage to empty
	f.Usage = func() {}

	return f
}
425649
func (c Flags) Int(name string) int {
	f := c.Get(name)
	if f == nil {
		return -1
	}
	return *f.Value.(*int)
}
114283
func (f *Flags) PrintHelp() {
	fmt.Fprintf(f.writer, "Usage of %s:\n", f.appName)
	fmt.Fprintf(f.writer, "%s\n", helpMessage)
	fmt.Fprintf(f.writer, "FLAGS\n")
	f.flagSet.PrintDefaults()
}
993387
func (c Flags) Get(name string) *Flag {
	for idx, v := range c {
		if v.Name == name {
			return c[idx]
		}
	}

	return nil
}
826661
func flags(cmd *cobra.Command) {
	cmd.Flags().VisitAll(func(f *flag.Flag) {
		if !f.Hidden {
			fmt.Printf("--%s ", f.Name)
		}
	})
}
671417
func newFlagset(name string, structValue reflect.Value, parent *FlagSet) *FlagSet {
	var once sync.Once
	r := &FlagSet{
		Name:     name,
		Flags:    make([]*Flag, 0),
		HelpFunc: DefaultHelpFunc,
		parent:   parent,
	}

	if parent != nil && parent.remainderFlag != nil {
		r.remainderFlag = parent.remainderFlag
	}

	var i int
	// Parse Option fields
	for i = 0; i < structValue.Type().NumField(); i++ {
		// Skip unexported fields
		if StartsWithLowercase(structValue.Type().Field(i).Name) {
			continue
		}

		fieldValue := structValue.Field(i)
		tag := structValue.Type().Field(i).Tag.Get("goptions")
		flag, err := parseStructField(fieldValue, tag)

		if err != nil {
			panic(fmt.Sprintf("Invalid struct field: %s", err))
		}
		if fieldValue.Type().Name() == "Verbs" {
			r.verbFlag = flag
			break
		}
		if fieldValue.Type().Name() == "Help" {
			r.helpFlag = flag
		}
		if fieldValue.Type().Name() == "Remainder" && r.remainderFlag == nil {
			r.remainderFlag = flag
		}

		if len(tag) != 0 {
			r.Flags = append(r.Flags, flag)
		}
	}

	// Parse verb fields
	for i++; i < structValue.Type().NumField(); i++ {
		once.Do(func() {
			r.Verbs = make(map[string]*FlagSet)
		})
		fieldValue := structValue.Field(i)
		tag := structValue.Type().Field(i).Tag.Get("goptions")
		r.Verbs[tag] = newFlagset(tag, fieldValue, r)
	}
	r.createMaps()
	return r
}
360749
func (b IPv4) Flags() uint8 {
	return uint8(binary.BigEndian.Uint16(b[flagsFO:]) >> 13)
}
1186490
func (nfs *NamedFlagSets) FlagSet(name string) *pflag.FlagSet {
	if nfs.FlagSets == nil {
		nfs.FlagSets = map[string]*pflag.FlagSet{}
	}
	if _, ok := nfs.FlagSets[name]; !ok {
		nfs.FlagSets[name] = pflag.NewFlagSet(name, pflag.ExitOnError)
		nfs.Order = append(nfs.Order, name)
	}
	return nfs.FlagSets[name]
}
1166421
func (c Flags) Validate() error {
	var notFilled []string
	for _, v := range c {
		// if no value given (nil) for required flag then it is not valid
		isRequired := v.Default == nil
		val := reflect.ValueOf(v.Value).Elem().String()
		if isRequired && val == "" {
			notFilled = append(notFilled, v.Name)
		}
	}

	if len(notFilled) > 0 {
		if len(notFilled) == 1 {
			return errFlagMissing.Format(notFilled[0])
		}
		return errFlagMissing.Format(strings.Join(notFilled, ","))

	}
	return nil

}
338768
func DefineFlagsFor(name string) {
	if plugSet, ok := pluginFlags[name]; ok {
		plugSet.VisitAll(func(f *flag.Flag) {
			flag.CommandLine.Var(f.Value, f.Name, f.Usage)
		})
	}
}
1358221
func PrintFlags(flags *pflag.FlagSet) {
	flags.VisitAll(func(flag *pflag.Flag) {
		klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
	})
}