Skip to content

feat(sheets): add tab management commands (add-tab, rename-tab, delete-tab)#309

Closed
JulienMalige wants to merge 2 commits intoopenclaw:mainfrom
JulienMalige:feat/sheets-tab-management
Closed

feat(sheets): add tab management commands (add-tab, rename-tab, delete-tab)#309
JulienMalige wants to merge 2 commits intoopenclaw:mainfrom
JulienMalige:feat/sheets-tab-management

Conversation

@JulienMalige
Copy link
Copy Markdown

Summary

Adds three new subcommands for managing tabs/sheets within a spreadsheet, using the Sheets API batchUpdate endpoint:

  • gog sheets add-tab <spreadsheetId> <tabName> — Create a new tab/sheet
  • gog sheets rename-tab <spreadsheetId> <oldName> <newName> — Rename an existing tab
  • gog sheets delete-tab <spreadsheetId> <tabName> — Delete a tab (requires --force or interactive confirmation)

Motivation

The existing sheets commands support reading/writing cell data (get, update, append, clear), formatting (format), inserting rows/columns (insert), and creating spreadsheets (create), but there is no way to manage the tabs themselves within an existing spreadsheet. This is a common need when programmatically building multi-tab spreadsheets.

Implementation

Uses BatchUpdateSpreadsheetRequest with:

  • AddSheetRequest for add-tab
  • UpdateSheetPropertiesRequest (fields: title) for rename-tab
  • DeleteSheetRequest for delete-tab

Follows the same patterns as sheets insert (PR #203) — uses fetchSheetIDMap for tab name → sheet ID resolution, confirmDestructive for delete safety, and supports --json output and --dry-run.

Usage

# Add a new tab
gog sheets add-tab 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms "Q1 Data"

# Rename a tab
gog sheets rename-tab 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms "Sheet1" "Summary"

# Delete a tab (with confirmation)
gog sheets delete-tab 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms "Old Data"

# Delete without confirmation
gog sheets delete-tab --force 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms "Old Data"

Testing

  • 5 unit tests with httptest mock server covering:
    • add-tab — verifies AddSheet request with correct title
    • rename-tab — verifies UpdateSheetProperties with correct sheet ID, title, and fields mask
    • delete-tab --force — verifies DeleteSheet with correct sheet ID
    • rename-tab unknown tab — error handling
    • delete-tab unknown tab — error handling
  • Note: existing contacts_crud.go has pre-existing type errors on main that prevent full go build ./...; this PR does not touch that file

New files

File Description
internal/cmd/sheets_tab.go Implementation (226 lines)
internal/cmd/sheets_tab_test.go Tests (147 lines)
internal/cmd/sheets.go +3 lines registering commands

…e-tab)

Add three new subcommands for managing tabs/sheets within a spreadsheet:

- `gog sheets add-tab <spreadsheetId> <tabName>` — creates a new tab
- `gog sheets rename-tab <spreadsheetId> <oldName> <newName>` — renames a tab
- `gog sheets delete-tab <spreadsheetId> <tabName>` — deletes a tab (requires --force or confirmation)

Uses the Sheets API batchUpdate with AddSheet, UpdateSheetProperties, and
DeleteSheet requests, following the same patterns as the existing insert
and format commands.

Includes unit tests with httptest mock server covering all three commands
plus error cases for unknown tab names.
@JulienMalige
Copy link
Copy Markdown
Author

Closes #310

@JulienMalige
Copy link
Copy Markdown
Author

Note: The build has pre-existing compile errors in internal/cmd/contacts_crud.go (lines 250, 266 — function signatures use Go's grouped parameter syntax which swaps string/bool types). These are on main and unrelated to this PR.

All 3 new commands tested successfully against a live spreadsheet:

  • sheets add-tab
  • sheets rename-tab
  • sheets delete-tab --force

@williamhrs
Copy link
Copy Markdown

this is very nice indeed! thanks for this pr

@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 8, 2026

Landed directly on main from a current-main rebase.

  • Gate: make ci
  • Land commits: d203ae3c11dcb86c564bdfe16cf19e16696b1894, 647f3f6c7738c7eae7e980aa8f69fe8c94f7bc92
  • Note: PR head repo is no longer available, so the rebased branch could not be pushed back for a normal PR merge.

Thanks @JulienMalige!

@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 8, 2026

Closing after direct land on main in d203ae3 + 647f3f6; PR head repo is no longer available for a normal merge update.

@steipete steipete closed this Mar 8, 2026
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
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.

3 participants