Skip to content

feat(cli): add --tab flag for per-tab Google Doc export#535

Closed
johnbenjaminlewis wants to merge 3 commits intoopenclaw:mainfrom
johnbenjaminlewis:feat/docs-tab-export
Closed

feat(cli): add --tab flag for per-tab Google Doc export#535
johnbenjaminlewis wants to merge 3 commits intoopenclaw:mainfrom
johnbenjaminlewis:feat/docs-tab-export

Conversation

@johnbenjaminlewis
Copy link
Copy Markdown
Contributor

feat(cli): add --tab flag for per-tab Google Doc export

Depends on: #532 and #534 (will rebase once those land)

Adds --tab to gog docs export and gog drive download to export a single tab by title or ID:

gog docs export <docId> --tab "New Tab" --format md
gog drive download <docId> --tab "New Tab" --format pdf
  • Supports pdf, docx, txt, md, and html
  • Uses an undocumented per-tab export endpoint (flagged as (experimental)) with redirect detection for auth failures
  • DriveDownloadCmd now runs normalizeGoogleID on file IDs (supports pasted URLs)

Test plan

  • Unit tests cover format mapping, URL construction, output paths, redirect policy, content-type sniffing, JSON output, and routing from both docs export --tab and drive download --tab
  • Manual test plan:
gog docs create "tab-test" --json           # grab $DOC_ID
gog docs list-tabs $DOC_ID --json           # add a second tab in UI first
gog docs export $DOC_ID --tab "New Tab" --format txt --out /tmp/tab.txt
gog drive download $DOC_ID --tab "New Tab" --format pdf --out /tmp/tab.pdf
gog docs export $DOC_ID --tab "NoSuchTab" --format pdf  # should list available tabs

Return an error from findTab instead of nil, listing available tab
titles when no match is found. This gives users actionable feedback
instead of a bare "tab not found" message.

Made-with: Cursor
…ient

Factor out the OAuth transport setup from optionsForAccountScopes into
a reusable authenticatedTransport helper. Expose NewHTTPClient so
callers that need a raw *http.Client (e.g. for custom redirect
policies) can get one without going through the google-api-go options
layer.
Add experimental --tab flag to `gog docs export` and `gog drive download`
that exports a single tab from a Google Doc by title or ID. Uses the
undocumented per-tab Docs export endpoint with a custom redirect policy
that rejects non-Google redirects to detect auth failures early.
@johnbenjaminlewis johnbenjaminlewis changed the title Feat/docs tab export feat(cli): add --tab flag for per-tab Google Doc export Apr 27, 2026
@steipete
Copy link
Copy Markdown
Collaborator

Landed on main in 26e01cf and 1763b39.

What landed:

  • kept the docs export --tab / drive download --tab feature from the PR
  • reused the already-landed authenticated HTTP client from refactor(googleapi): extract authenticatedTransport and add NewHTTPCl… #534
  • added maintainer hardening for Google sign-in redirects, case-insensitive format/content-type handling, and --out - / --json --out - parity with existing exports
  • added docs, generated command reference, changelog credit, and stdout/auth regression coverage

Verification:

  • live smoke against steipete@gmail.com with a temporary Google Doc: docs export --tab as txt, md, html, and pdf; drive download --tab; missing-tab error; and --out - raw stdout behavior
  • go test ./internal/cmd -run 'Test(TabExport|GoogleExport|RunDocsTabExport|DocsExportCmd_Tab|DriveDownloadCmd_Tab)' -count=1
  • make lint
  • make test
  • make ci

Thanks @johnbenjaminlewis.

@steipete
Copy link
Copy Markdown
Collaborator

Closing as landed on main in 26e01cf and 1763b39. Thanks again @johnbenjaminlewis.

@steipete steipete closed this Apr 28, 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.

2 participants