MCPcopy
hub / github.com/spf13/pflag / ShorthandLookup

Method ShorthandLookup

flag.go:385–396  ·  view source on GitHub ↗

ShorthandLookup returns the Flag structure of the short handed flag, returning nil if none exists. It panics, if len(name) > 1.

(name string)

Source from the content-addressed store, hash-verified

383// returning nil if none exists.
384// It panics, if len(name) > 1.
385func (f *FlagSet) ShorthandLookup(name string) *Flag {
386 if name == "" {
387 return nil
388 }
389 if len(name) > 1 {
390 msg := fmt.Sprintf("can not look up shorthand which is more than one ASCII character: %q", name)
391 fmt.Fprintf(f.Output(), msg)
392 panic(msg)
393 }
394 c := name[0]
395 return f.shorthands[c]
396}
397
398// lookup returns the Flag structure of the named flag, returning nil if none exists.
399func (f *FlagSet) lookup(name NormalizedName) *Flag {

Callers 4

TestShorthandLookupFunction · 0.95
TestPrintDefaultsFunction · 0.95
ShorthandLookupFunction · 0.80

Calls 1

OutputMethod · 0.95

Tested by 3

TestShorthandLookupFunction · 0.76
TestPrintDefaultsFunction · 0.76