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

Method Run

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

Source from the content-addressed store, hash-verified

181}
182
183func (c *SheetsUpdateCmd) Run(ctx context.Context, flags *RootFlags) error {
184 u := ui.FromContext(ctx)
185
186 spreadsheetID := normalizeGoogleID(strings.TrimSpace(c.SpreadsheetID))
187 rangeSpec := cleanRange(c.Range)
188 if spreadsheetID == "" {
189 return usage("empty spreadsheetId")
190 }
191 if strings.TrimSpace(rangeSpec) == "" {
192 return usage("empty range")
193 }
194
195 var values [][]interface{}
196 switch {
197 case strings.TrimSpace(c.ValuesJSON) != "":
198 b, err := resolveInlineOrFileBytes(c.ValuesJSON, stdinReader(ctx))
199 if err != nil {
200 return usagef("read --values-json: %v", err)
201 }
202
203 values, err = sheetsvalues.DecodeStrict(b)
204 if err != nil {
205 return sheetsValuesPlannerError(err)
206 }
207 case len(c.Values) > 0:
208 values = sheetsvalues.ParseArgs(c.Values)
209 default:
210 return usage("provide values as args or via --values-json")
211 }
212
213 valueInputOption := strings.TrimSpace(c.ValueInput)
214 if valueInputOption == "" {
215 valueInputOption = sheetsDefaultValueInputOption
216 }
217
218 if err := dryRunExit(ctx, flags, "sheets.update", map[string]any{
219 "spreadsheet_id": spreadsheetID,
220 "range": rangeSpec,
221 "values": values,
222 "value_input_option": valueInputOption,
223 "copy_validation_from": strings.TrimSpace(c.CopyValidationFrom),
224 "copy_validation_to_hint": "updatedRange",
225 "fail_on_formula_error": c.FailOnFormulaError,
226 }); err != nil {
227 return err
228 }
229
230 account, err := requireAccount(flags)
231 if err != nil {
232 return err
233 }
234
235 svc, err := sheetsService(ctx, account)
236 if err != nil {
237 return err
238 }
239
240 vr := &sheets.ValueRange{

Callers

nothing calls this directly

Calls 15

FromContextFunction · 0.92
DecodeStrictFunction · 0.92
ParseArgsFunction · 0.92
IsJSONFunction · 0.92
WriteJSONFunction · 0.92
normalizeGoogleIDFunction · 0.85
cleanRangeFunction · 0.85
usageFunction · 0.85
resolveInlineOrFileBytesFunction · 0.85
stdinReaderFunction · 0.85
usagefFunction · 0.85
sheetsValuesPlannerErrorFunction · 0.85

Tested by

no test coverage detected