MCPcopy
hub / github.com/urfave/cli / LocalFlagNames

Method LocalFlagNames

command.go:520–543  ·  view source on GitHub ↗

LocalFlagNames returns a slice of flag names used in this command.

()

Source from the content-addressed store, hash-verified

518// LocalFlagNames returns a slice of flag names used in this
519// command.
520func (cmd *Command) LocalFlagNames() []string {
521 names := []string{}
522
523 // Check the flags which have been set via env or file
524 for _, f := range cmd.allFlags() {
525 if f.IsSet() {
526 names = append(names, f.Names()...)
527 }
528 }
529
530 // Sort out the duplicates since flag could be set via multiple
531 // paths
532 m := map[string]struct{}{}
533 uniqNames := []string{}
534
535 for _, name := range names {
536 if _, ok := m[name]; !ok {
537 m[name] = struct{}{}
538 uniqNames = append(uniqNames, name)
539 }
540 }
541
542 return uniqNames
543}
544
545// FlagNames returns a slice of flag names used by the this command
546// and all of its parent commands.

Callers 2

TestCommand_NumFlagsFunction · 0.95
FlagNamesMethod · 0.95

Calls 3

allFlagsMethod · 0.95
IsSetMethod · 0.65
NamesMethod · 0.65

Tested by 1

TestCommand_NumFlagsFunction · 0.76