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

Method Run

internal/cmd/sheets_table_append.go:24–107  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

22}
23
24func (c *SheetsTableAppendCmd) Run(ctx context.Context, flags *RootFlags) error {
25 u := ui.FromContext(ctx)
26 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
27 in := strings.TrimSpace(c.TableID)
28 if spreadsheetID == "" {
29 return usage("empty spreadsheetId")
30 }
31 if in == "" {
32 return usage("empty tableId")
33 }
34
35 values, err := parseSheetsAppendValues(c.ValuesJSON, c.Values, stdinReader(ctx))
36 if err != nil {
37 return err
38 }
39 valueInputOption := strings.TrimSpace(c.ValueInput)
40 if valueInputOption == "" {
41 valueInputOption = sheetsDefaultValueInputOption
42 }
43
44 if dryRunErr := dryRunExit(ctx, flags, "sheets.table.append", map[string]any{
45 "spreadsheet_id": spreadsheetID,
46 "table_id_or_name": in,
47 "values": values,
48 "value_input_option": valueInputOption,
49 "insert_data_option": "INSERT_ROWS",
50 }); dryRunErr != nil {
51 return dryRunErr
52 }
53
54 account, err := requireAccount(flags)
55 if err != nil {
56 return err
57 }
58
59 svc, err := sheetsService(ctx, account)
60 if err != nil {
61 return err
62 }
63
64 tables, err := fetchSpreadsheetTables(ctx, svc, spreadsheetID)
65 if err != nil {
66 return err
67 }
68 table, found, err := resolveSheetsTable(in, tables)
69 if err != nil {
70 return err
71 }
72 if !found {
73 return usagef("unknown table %q", in)
74 }
75 if strings.TrimSpace(table.A1) == "" {
76 return fmt.Errorf("table %q has no bounded A1 range", table.TableID)
77 }
78 if widthErr := validateSheetsTableAppendWidth(table, values); widthErr != nil {
79 return widthErr
80 }
81

Callers

nothing calls this directly

Calls 15

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
normalizeGoogleIDFunction · 0.85
usageFunction · 0.85
parseSheetsAppendValuesFunction · 0.85
stdinReaderFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
sheetsServiceFunction · 0.85
fetchSpreadsheetTablesFunction · 0.85
resolveSheetsTableFunction · 0.85

Tested by

no test coverage detected