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

Method Parse

args.go:110–136  ·  view source on GitHub ↗
(s []string)

Source from the content-addressed store, hash-verified

108}
109
110func (a *ArgumentBase[T, C, VC]) Parse(s []string) ([]string, error) {
111 tracef("calling arg%[1] parse with args %[2]", a.Name, s)
112
113 var vc VC
114 var t T
115 value := vc.Create(a.Value, &t, a.Config)
116 a.value = &t
117
118 tracef("attempting arg%[1] parse", &a.Name)
119 if len(s) > 0 {
120 if err := value.Set(s[0]); err != nil {
121 return s, fmt.Errorf("invalid value %q for argument %s: %v", s[0], a.Name, err)
122 }
123 *a.value = value.Get().(T)
124 tracef("set arg%[1] one value", a.Name, *a.value)
125 }
126
127 if a.Destination != nil {
128 tracef("setting destination")
129 *a.Destination = *a.value
130 }
131
132 if len(s) > 0 {
133 return s[1:], nil
134 }
135 return s, nil
136}
137
138func (a *ArgumentBase[T, C, VC]) Get() any {
139 if a.value != nil {

Callers

nothing calls this directly

Calls 4

tracefFunction · 0.85
CreateMethod · 0.65
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected