Skip to content

feat(docs): add --tab flag to editing commands (write, insert, delete, find-replace) #323

Description

@ignacioreyna

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions