| 108 | } |
| 109 | |
| 110 | func (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 | |
| 138 | func (a *ArgumentBase[T, C, VC]) Get() any { |
| 139 | if a.value != nil { |