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

Function flagFromError

command_parse.go:16–23  ·  view source on GitHub ↗

flagFromError tries to parse a provided flag from an error message. If the parsing fails, it returns the input error and an empty string

(err error)

Source from the content-addressed store, hash-verified

14// flagFromError tries to parse a provided flag from an error message. If the
15// parsing fails, it returns the input error and an empty string
16func flagFromError(err error) (string, error) {
17 errStr := err.Error()
18 trimmed := strings.TrimPrefix(errStr, providedButNotDefinedErrMsg)
19 if errStr == trimmed {
20 return "", err
21 }
22 return trimmed, nil
23}
24
25func (cmd *Command) parseFlags(args Args) (Args, error) {
26 tracef("parsing flags from arguments %[1]q (cmd=%[2]q)", args, cmd.Name)

Callers 1

suggestFlagFromErrorMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected