MCPcopy
hub / github.com/spf13/cobra / findFlag

Function findFlag

completions.go:929–946  ·  view source on GitHub ↗
(cmd *Command, name string)

Source from the content-addressed store, hash-verified

927}
928
929func findFlag(cmd *Command, name string) *pflag.Flag {
930 flagSet := cmd.Flags()
931 if len(name) == 1 {
932 // First convert the short flag into a long flag
933 // as the cmd.Flag() search only accepts long flags
934 if short := flagSet.ShorthandLookup(name); short != nil {
935 name = short.Name
936 } else {
937 set := cmd.InheritedFlags()
938 if short = set.ShorthandLookup(name); short != nil {
939 name = short.Name
940 } else {
941 return nil
942 }
943 }
944 }
945 return cmd.Flag(name)
946}
947
948// CompDebug prints the specified string to the same file as where the
949// completion script prints its logs.

Callers 1

checkIfFlagCompletionFunction · 0.85

Calls 3

FlagsMethod · 0.80
InheritedFlagsMethod · 0.80
FlagMethod · 0.80

Tested by

no test coverage detected