Summary
PR #225 added Google Docs tab support for reading (cat --tab, cat --all-tabs, list-tabs) but the editing commands don't yet support targeting a specific tab. They always operate on the first/default tab.
Affected commands
gog docs write — append/replace content (plain text and markdown)
gog docs insert — insert text at index
gog docs delete — delete text range
gog docs find-replace — find and replace text
gog docs update — update content (plain text and markdown with --append)
Proposed change
Add a --tab-id <id> flag to each editing command. The flag takes a raw tab ID (obtainable via gog docs list-tabs). No title resolution — keeps the CLI thin with no extra API calls on the write path.
The Google Docs API supports this via the TabId field on Location, Range, EndOfSegmentLocation, and TabsCriteria in batch update requests.
Behavior
- When
--tab-id is omitted: current behavior (targets first/default tab)
- When
--tab-id is provided: set TabId on the relevant API request structs
write --markdown --tab-id: uses Docs API batch approach (ParseMarkdown → MarkdownToDocsRequests) instead of Drive API import, since Drive API can't target tabs
Design rationale
--tab-id (raw ID) over --tab (title+ID): editing commands don't need to fetch the doc before writing, so title resolution would add an unnecessary API roundtrip. Clients get tab IDs via gog docs list-tabs.
cat --tab stays as-is: it already fetches the doc, so title resolution is free there.
References
Summary
PR #225 added Google Docs tab support for reading (
cat --tab,cat --all-tabs,list-tabs) but the editing commands don't yet support targeting a specific tab. They always operate on the first/default tab.Affected commands
gog docs write— append/replace content (plain text and markdown)gog docs insert— insert text at indexgog docs delete— delete text rangegog docs find-replace— find and replace textgog docs update— update content (plain text and markdown with --append)Proposed change
Add a
--tab-id <id>flag to each editing command. The flag takes a raw tab ID (obtainable viagog docs list-tabs). No title resolution — keeps the CLI thin with no extra API calls on the write path.The Google Docs API supports this via the
TabIdfield onLocation,Range,EndOfSegmentLocation, andTabsCriteriain batch update requests.Behavior
--tab-idis omitted: current behavior (targets first/default tab)--tab-idis provided: setTabIdon the relevant API request structswrite --markdown --tab-id: uses Docs API batch approach (ParseMarkdown → MarkdownToDocsRequests) instead of Drive API import, since Drive API can't target tabsDesign rationale
--tab-id(raw ID) over--tab(title+ID): editing commands don't need to fetch the doc before writing, so title resolution would add an unnecessary API roundtrip. Clients get tab IDs viagog docs list-tabs.cat --tabstays as-is: it already fetches the doc, so title resolution is free there.References