MCPcopy Create free account
hub / github.com/openclaw/gogcli / resolveSheetsTable

Function resolveSheetsTable

internal/cmd/sheets_table.go:379–409  ·  view source on GitHub ↗
(input string, tables []sheetsTableItem)

Source from the content-addressed store, hash-verified

377}
378
379func resolveSheetsTable(input string, tables []sheetsTableItem) (sheetsTableItem, bool, error) {
380 in := strings.TrimSpace(input)
381 if in == "" {
382 return sheetsTableItem{}, false, nil
383 }
384
385 for _, table := range tables {
386 if table.TableID == in {
387 return table, true, nil
388 }
389 }
390
391 var matches []sheetsTableItem
392 for _, table := range tables {
393 if strings.EqualFold(table.Name, in) {
394 matches = append(matches, table)
395 }
396 }
397 switch len(matches) {
398 case 0:
399 return sheetsTableItem{}, false, nil
400 case 1:
401 return matches[0], true, nil
402 default:
403 parts := make([]string, 0, len(matches))
404 for _, match := range matches {
405 parts = append(parts, fmt.Sprintf("%s (%s)", match.Name, match.TableID))
406 }
407 return sheetsTableItem{}, false, usagef("ambiguous table %q; matches: %s", in, strings.Join(parts, ", "))
408 }
409}

Callers 4

RunMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85
RunMethod · 0.85

Calls 1

usagefFunction · 0.85

Tested by

no test coverage detected