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

Method Flag

command.go:1844–1852  ·  view source on GitHub ↗

Flag climbs up the command tree looking for matching flag.

(name string)

Source from the content-addressed store, hash-verified

1842
1843// Flag climbs up the command tree looking for matching flag.
1844func (c *Command) Flag(name string) (flag *flag.Flag) {
1845 flag = c.Flags().Lookup(name)
1846
1847 if flag == nil {
1848 flag = c.persistentFlag(name)
1849 }
1850
1851 return
1852}
1853
1854// Recursively find matching persistent flag.
1855func (c *Command) persistentFlag(name string) (flag *flag.Flag) {

Callers 3

GetFlagCompletionFuncMethod · 0.95
findFlagFunction · 0.80

Calls 2

FlagsMethod · 0.95
persistentFlagMethod · 0.95

Tested by

no test coverage detected