feat(docs): add set-page-layout for existing docs (#593)#624
Merged
Conversation
Adds `gog docs set-page-layout <docId> [--layout=pageless|paged]` so documents that were created upstream (e.g. by Drive markdown conversion or another non-gog tool) can have their page layout flipped without touching the UI. Sibling to the existing `--pageless` flag on `docs create`/`write`/`update`, which only fires on creation. Implementation: refactors the existing `setDocumentPageless` helper into a general `setDocumentMode(svc, docID, mode)` that issues a single `documents.batchUpdate` with `updateDocumentStyle` on `documentFormat.documentMode` (PAGELESS / PAGES). The existing flag path delegates to it, so behaviour is unchanged. The Docs Go SDK exposes the layout toggle via `DocumentStyle.DocumentFormat.DocumentMode` rather than the `DocumentStyle.Pageless` boolean shown in some REST docs — the latter is not present on the generated Go type. Tests cover: - default `--layout=pageless` emits the expected batchUpdate shape (UpdateDocumentStyle, fields=documentFormat, mode=PAGELESS) - `--layout=paged` emits mode=PAGES - invalid `--layout` values are rejected by Kong enum validation - empty docId is rejected - dry-run does not open the docs service - `normalizePageLayout` accepts case/whitespace variants of pageless/paged/pages CHANGELOG entry added under 0.17.1. Closes openclaw#593
steipete
force-pushed
the
feat/593-pageless
branch
from
May 22, 2026 00:00
0bba5e4 to
7b8c451
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
gog docs set-page-layout <docId> [--layout=pageless|paged]so an existing Google Doc's page layout can be flipped from the CLI. Sibling to the existing--pagelessflag ondocs create/write/update, which only fires on creation — this verb covers docs created upstream (Drive markdown conversion, copy-from-template, etc.) that landed in the wrong layout.Aliases:
page-setup,page-layout. Defaults to--layout=pageless(the case agent-generated multi-tab + table-heavy specs actually want).Implementation
setDocumentPagelesshelper into a generalsetDocumentMode(svc, docID, mode)issuing a singledocuments.batchUpdatewithupdateDocumentStyleondocumentFormat.documentMode(PAGELESS/PAGES). The existing flag path delegates to it — no behaviour change there.DocsSetPageLayoutCmdlives ininternal/cmd/docs_set_page_layout.go, mirroring the shape ofDocsInsertPageBreakCmd(arg<docId>, dry-run support, JSON / plain output,isDocsNotFoundtranslation).enum:tag on--layoutrejects bad values at parse time;normalizePageLayoutadditionally accepts case/whitespace variants and the convenience aliaspages.The Docs Go SDK exposes the layout toggle via
DocumentStyle.DocumentFormat.DocumentModerather than theDocumentStyle.Pagelessboolean some REST references mention — the boolean is not present on the generated Go type, so this is the correct field.Tests
internal/cmd/docs_set_page_layout_test.gocovers:--layoutdefault (pageless) emits the expected batchUpdate (UpdateDocumentStyle,fields=documentFormat,documentMode=PAGELESS)--layout=pagedemitsdocumentMode=PAGES--layout=portraitrejected by Kong enum validationusage("empty docId")normalizePageLayouttable test for case / whitespace / alias inputsExisting
TestDocsCreate_Pagelesscontinues to pass — the refactor is wire-compatible.Test plan
go vet ./internal/cmd/go test -count=1 -run 'TestDocsSetPageLayoutCmd|TestNormalizePageLayout|TestDocsCreate_Pageless' ./internal/cmd/— greengo test -count=1 ./internal/cmd/— full package green (54s)Closes #593
🤖 Generated with Claude Code