feat(slides): add insert-text and replace-text commands#521
Closed
chrissanchez-iops wants to merge 1 commit intoopenclaw:mainfrom
Closed
feat(slides): add insert-text and replace-text commands#521chrissanchez-iops wants to merge 1 commit intoopenclaw:mainfrom
chrissanchez-iops wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Thin wrappers around presentations.batchUpdate for surgical text edits on an existing deck. - insert-text inserts text into a page element by objectId, with --insertion-index, --replace (emits DeleteText+InsertText), and stdin support via '-'. - replace-text runs ReplaceAllText across the deck, with --match-case and repeatable --page for slide-scoped replacements. Both honor the global --dry-run (prints the batchUpdate request body as JSON without calling the API) and --json (emits the full BatchUpdatePresentationResponse). Plain output gives a one-line confirmation with revisionId + replies/replaced count. Style mirrors existing update-notes and replace-slide commands.
Collaborator
|
Thanks @chrissanchez-iops, landed this on main. Landed commits:
Maintainer follow-up included:
Verification:
|
Collaborator
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.
Motivation
Today,
gog slidescan:update-notes— edit speaker notes on an existing slidereplace-slide— swap a whole image in-placecreate-from-markdown/create-from-template— build new decks…but there is no way to programmatically write text into an existing slide's text box or table cell. That gap makes it awkward to patch decks in place from scripts and agents (e.g. filling a shape whose
objectIdyou already know, or doing{{token}}replacements in a template that has already been copied).These two commands close the gap using the Slides API primitives already used internally elsewhere in this file:
presentations.batchUpdatewithInsertTextRequest(+ optionalDeleteTextRequestfor a clean replace) →gog slides insert-textpresentations.batchUpdatewithReplaceAllTextRequest→gog slides replace-textThey are intentionally thin wrappers; no business logic, no new auth scopes, no new dependencies. Style mirrors
update-notesandreplace-slideexactly (same flag conventions, same error messages, same test patterns).What's added
gog slides insert-text <presentationId> <objectId> <text>Inserts text into an existing text-capable page element by its Slides API
objectId.Flags
--insertion-index <int>0--replacefalseDeleteText(range=ALL) followed byInsertTextin a single batch--dry-run(global)falseBatchUpdatePresentationRequestas JSON to stdout and exits; no API call, no auth needed--json(global)BatchUpdatePresentationResponse(revisionId + replies)<text><text>is-, reads from stdin (useful for long or piped content)gog slides replace-text <presentationId> <find> <replacement>Find-and-replace across the whole deck.
Flags
--match-casefalseSubstringMatchCriteria.matchCase)--page <objectId>(repeatable)pageObjectIds)--dry-run(global)false--json(global)BatchUpdatePresentationResponsePlain output (both commands)
Testing
Unit tests (
make test)Five
insert-texttests and fourreplace-texttests, all using the samehttptest-backed pattern asslides_update_notes_test.go:insert-text: basic insert (captures InsertText + verifies index),--replaceemits DeleteText→InsertText in one batch, stdin via-,--dry-runproduces valid JSON and makes zero API calls, emptyobjectIderrors before auth.replace-text: basic replace with revisionId + occurrences,--match-case+--pagescoping,--dry-runproduces valid JSON, emptyfinderrors before auth.make cipasses cleanly:Integration tests (live API, throwaway deck)
Ran the full matrix against a
gogcli-pr-test-*deck I created viacreate-from-markdown(then cleaned up withdrive delete --force). Excerpts:Scope
SlidesCmd.presentationsscope already set forslides.google.golang.org/api/slides/v1.slides_update_notes.go/slides_replace_slide.go.### Slidesexamples section.Files
internal/cmd/slides_insert_text.go(new)internal/cmd/slides_insert_text_test.go(new)internal/cmd/slides_replace_text.go(new)internal/cmd/slides_replace_text_test.go(new)internal/cmd/slides.go(+2 lines: command registration)README.md(usage examples)