(idx int, newValue string)
| 181 | } |
| 182 | |
| 183 | func (m configTabModel) submitEdit(idx int, newValue string) tea.Cmd { |
| 184 | return func() tea.Msg { |
| 185 | f := m.fields[idx] |
| 186 | var err error |
| 187 | var value any |
| 188 | switch f.kind { |
| 189 | case "int": |
| 190 | valueInt, errAtoi := strconv.Atoi(newValue) |
| 191 | if errAtoi != nil { |
| 192 | return configUpdateMsg{ |
| 193 | path: f.apiPath, |
| 194 | err: fmt.Errorf("%s: %s", T("invalid_int"), newValue), |
| 195 | } |
| 196 | } |
| 197 | value = valueInt |
| 198 | err = m.client.PutIntField(f.apiPath, valueInt) |
| 199 | case "string": |
| 200 | value = newValue |
| 201 | err = m.client.PutStringField(f.apiPath, newValue) |
| 202 | } |
| 203 | return configUpdateMsg{ |
| 204 | path: f.apiPath, |
| 205 | value: value, |
| 206 | err: err, |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | func configFieldEditValue(f configField) string { |
| 212 | if rawString, ok := f.rawValue.(string); ok { |
no test coverage detected