// Flag is specified on the Scene interface.
962119
func (s *scene) Flag(topic string) error {
	command := &envelope{
		kind: flag,
		signaling: &signaling{
			topic: topic,
		},
		respChan: make(chan *envelope, 1),
	}
	_, err := s.command(command)
	return err
}
1124221
func FlagIt(v interface{}) (fs *flag.FlagSet) {
	val := reflect.ValueOf(v).Elem()
	structName := val.Type().Name()

	// Create FlagSet
	fs = flag.NewFlagSet(structName, flag.ContinueOnError)
	// for each field in struct
	for i := 0; i < val.NumField(); i++ {
		FlagByType(fs, structName, val.Field(i), val.Type().Field(i))
	}
	return fs
}
826661
func flags(cmd *cobra.Command) {
	cmd.Flags().VisitAll(func(f *flag.Flag) {
		if !f.Hidden {
			fmt.Printf("--%s ", f.Name)
		}
	})
}
654191
func Flag(name string, defv interface{}, usage string) V {
	return flagA(flagT{
		name:  name,
		defv:  defv,
		usage: usage,
	})
}
1186316
func (c *TechSupportCommand) VisitAllFlags(fn func(*flag.Flag)) {
	c.flags.VisitAll(fn)
}
490445
func (a Attributes) Flag(flag string) bool {
	for _, v := range a {
		if v.Key == flag {
			return true
		}
	}
	return false
}
1088757
func (cl *CommandLine) AddFlag(flag CommandLineFlag) {
	if strings.HasPrefix(flag.Flag, "-") {
		panic("flag must not begin with '-'")
	}
	for _, f := range cl.Flags {
		if f == flag {
			return
		}
	}
	cl.Flags = append(cl.Flags, flag)
}
294302
func (f Flag) Alias() string {
	if len(f.Name) > 1 {
		return f.Name[0:1]
	}
	return f.Name
}
1014274
func (cl *CommandLine) AddSingleFlag(flag string) {
	cl.AddFlag(CommandLineFlag{Flag: flag})
}
348067
func (cl *CoLog) SetFlags(flags int) {
	cl.mu.Lock()
	defer cl.mu.Unlock()
	if cl.formatter == nil {
		return
	}

	cl.formatter.SetFlags(flags)
}
181811
func (m *Message) Flag(flag string) bool {
	if len(m.Attributes) > 0 {
		return m.Attributes.Flag(flag)
	}
	return false
}
898856
func (f *FlagClause) PlaceHolder(placeholder string) *FlagClause {
	f.placeholder = placeholder
	return 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
}
542891
func (p *Packet) Flags() (flags byte, present bool) {
	b := p.Field(flags)
	if len(b) < 2 {
		return 0, false
	}
	return b[2], true
}
1338294
func Flag(fs *flag.FlagSet) {
	for _, id := range All {
		desc := id.Flag()
		key := fmt.Sprintf("X%s", id.Flag())
		fs.Var(&idValue{X: id}, key, desc)
	}
}
480258
func (ef EnvFlag) ProcessFlagWithEnv() error {
	if ef.flagSet.Parsed() {
		return errors.New("flag has already been parsed")
	}
	flagEnvMap := map[string]string{}
	for k, v := range ef.envFlagDict {
		flagEnvMap[v] = k
	}
	// Rewrite flag.Useage and show env key in usage
	if ef.showEnvKeyInUsage {
		ef.flagSet.VisitAll(func(f *flag.Flag) {
			if len(f.Name) < ef.minLength {
				return
			}
			envKey, ok := flagEnvMap[f.Name]
			if !ok {
				envKey = flagToEnv(f.Name)
			}
			envPrefix := fmt.Sprintf("[%s]", envKey)
			if strings.HasPrefix(f.Usage, envPrefix) {
				return
			}
			f.Usage = fmt.Sprintf("%s %s", envPrefix, f.Usage)
		})
	}

	for _, envLine := range os.Environ() {
		debug("Find a new line of environment variable, ", envLine)
		envKV := strings.SplitN(envLine, "=", 2)
		var key, value string
		key = envKV[0]
		if len(key) < ef.minLength {
			continue
		}
		if len(envKV) > 1 {
			value = envKV[1]
		} else {
			value = ""
		}

		var flagKey string
		if userFlag, ok := ef.envFlagDict[key]; ok {
			flagKey = userFlag
		} else {
			flagKey = envToFlag(key)
		}
		debug("ENV ", key, " is converted to ", flagKey)
		f := ef.flagSet.Lookup(flagKey)
		if f == nil {
			debug(flagKey, " is not defined in flag, skip!")
			continue
		}

		if ef.showEnvValInUsage {
			// use env value as default value (in usage)
			f.DefValue = value
		}

		debug("Set  [", flagKey, ",", value, "] to flag")
		if err := ef.flagSet.Set(flagKey, value); err != nil {
			return fmt.Errorf("error when set [%s,%s] into flag\n", flagKey, value)
		}
	}
	return nil
}
912809
func (c *RFCCommand) VisitAllFlags(fn func(*flag.Flag)) {
	c.flags.VisitAll(fn)
}