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

Method Run

internal/cmd/sheets.go:372–440  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

370}
371
372func (c *SheetsBatchUpdateCmd) Run(ctx context.Context, flags *RootFlags) error {
373 u := ui.FromContext(ctx)
374
375 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
376 if spreadsheetID == "" {
377 return usage("empty spreadsheetId")
378 }
379
380 data, err := parseSheetsBatchUpdateData(c.DataJSON, stdinReader(ctx))
381 if err != nil {
382 return err
383 }
384
385 valueInputOption := strings.TrimSpace(c.ValueInput)
386 if valueInputOption == "" {
387 valueInputOption = sheetsDefaultValueInputOption
388 }
389 req := &sheets.BatchUpdateValuesRequest{
390 Data: data,
391 ValueInputOption: valueInputOption,
392 IncludeValuesInResponse: c.IncludeValuesInResponse,
393 }
394 if strings.TrimSpace(c.ResponseValueRenderOption) != "" {
395 req.ResponseValueRenderOption = strings.TrimSpace(c.ResponseValueRenderOption)
396 }
397 if strings.TrimSpace(c.ResponseDateTimeRenderOption) != "" {
398 req.ResponseDateTimeRenderOption = strings.TrimSpace(c.ResponseDateTimeRenderOption)
399 }
400
401 if dryRunErr := dryRunExit(ctx, flags, "sheets.batch-update", map[string]any{
402 "spreadsheet_id": spreadsheetID,
403 "value_input_option": req.ValueInputOption,
404 "include_values_in_response": req.IncludeValuesInResponse,
405 "response_value_render_option": req.ResponseValueRenderOption,
406 "response_date_time_render_option": req.ResponseDateTimeRenderOption,
407 "data": req.Data,
408 }); dryRunErr != nil {
409 return dryRunErr
410 }
411
412 account, err := requireAccount(flags)
413 if err != nil {
414 return err
415 }
416
417 svc, err := sheetsService(ctx, account)
418 if err != nil {
419 return err
420 }
421
422 resp, err := svc.Spreadsheets.Values.BatchUpdate(spreadsheetID, req).Do()
423 if err != nil {
424 return err
425 }
426
427 if outfmt.IsJSON(ctx) {
428 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{
429 "spreadsheetId": resp.SpreadsheetId,

Callers

nothing calls this directly

Calls 15

FromContextFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
normalizeGoogleIDFunction · 0.85
usageFunction · 0.85
stdinReaderFunction · 0.85
dryRunExitFunction · 0.85
requireAccountFunction · 0.85
sheetsServiceFunction · 0.85
stdoutWriterFunction · 0.85
LinefMethod · 0.80

Tested by

no test coverage detected