MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / submitEdit

Method submitEdit

internal/tui/config_tab.go:183–209  ·  view source on GitHub ↗
(idx int, newValue string)

Source from the content-addressed store, hash-verified

181}
182
183func (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
211func configFieldEditValue(f configField) string {
212 if rawString, ok := f.rawValue.(string); ok {

Callers 1

handleEditingKeyMethod · 0.95

Calls 3

TFunction · 0.85
PutIntFieldMethod · 0.80
PutStringFieldMethod · 0.80

Tested by

no test coverage detected