Skip to content

feat(sheets): add reorder-tab command#616

Open
chrischall wants to merge 2 commits into
openclaw:mainfrom
chrischall:feat/603-sheets-reorder-tab
Open

feat(sheets): add reorder-tab command#616
chrischall wants to merge 2 commits into
openclaw:mainfrom
chrischall:feat/603-sheets-reorder-tab

Conversation

@chrischall
Copy link
Copy Markdown

Closes #603.

Summary

Surfaces `spreadsheets.batchUpdate` → `updateSheetProperties` with field mask `index` as a standalone CLI subcommand. `add-tab`, `rename-tab`, and `delete-tab` were already exposed; reordering was the missing primitive (today the only workarounds are recreating tabs or hoping for alphabetical order via renames).

Usage

```
gog sheets reorder-tab --tab=<name|sheetId> --to=N
```

Aliases: `move-tab`, `reorder-sheet`, `move-sheet`.

Flag Notes
`--tab` Tab title OR numeric sheet ID. Numeric IDs are resolved without a name lookup so the command still works on tabs that share titles or have empty titles.
`--to` Destination 0-based tab index. `--to=0` is the leftmost position and is force-sent over the wire — Index would otherwise be elided as Go's zero value, leaving the API call a no-op.

Tests

  • `TestSheetsReorderTabCmd_ResolvesByName` — title → sheetId lookup via the existing `fetchSheetIDMap` helper.
  • `TestSheetsReorderTabCmd_AcceptsNumericSheetID` — numeric `--tab=99` passes through directly.
  • `TestSheetsReorderTabCmd_IndexZeroIsSerialized` — raw-body assertion that `"index":0` and `"fields":"index"` actually reach the wire when targeting position 0.
  • `TestSheetsReorderTabCmd_UnknownTabName` — unknown title returns a clean usage error.
  • `TestSheetsReorderTabCmd_NegativeIndexRejected` — `--to=-1` rejected with a precise message.

`go test ./internal/cmd/ -count=1` → ok 23.6s.

chrischall and others added 2 commits May 19, 2026 20:23
Closes openclaw#603.

Surfaces spreadsheets.batchUpdate -> updateSheetProperties with field
mask `index` as a standalone CLI subcommand. add-tab, rename-tab, and
delete-tab were already exposed; reordering was the missing primitive.

Usage:
  gog sheets reorder-tab <spreadsheetId> --tab=<name|sheetId> --to=N

Notes:
- --tab accepts a literal tab title OR a numeric sheet ID; numeric IDs
  are resolved without a name lookup so the command works on tabs that
  share titles or have empty titles.
- --to is the destination 0-based tab index; --to=0 is the leftmost
  position and is force-sent over the wire (Index would otherwise be
  elided as Go's zero value, leaving the API call a no-op).
- Aliases: move-tab, reorder-sheet, move-sheet.

Tests cover: name → sheetId resolution, numeric sheetId pass-through,
--to=0 reaching the wire as "index":0 (raw JSON inspection), unknown-
tab error, and the --to=-1 guard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sheets): add reorder-tab (move a tab to a specific position)

1 participant