feat(docs): add read and edit commands for Google Docs#370
feat(docs): add read and edit commands for Google Docs#370danhayman wants to merge 1 commit intosteipete:mainfrom
Conversation
feea460 to
f759477
Compare
|
Hi Dan - Thank you for the contribution. Can you take a look at #359 which I wrote (and just merged). It adds a flexible sed-syntax based document editing and formatting tool to gogcli. It's designed to be consistent across Google docs, sheets, slides, etc; and also across mogcli (the microsoft version of gogcli) and sogcli (the standards version of gogcli) I'm trying to 1. keep gog from have 5 different ways to edit docs and 2. have document editing features which will work across all three plugins. I'd like your opinion on what you think would be best:
Very much appreciated! |
|
Sorry @visionik, I lost this amongst all my work noise |
- Add `docs read` with character-based --offset/--limit pagination - Rewrite `docs edit` to use --old/--new with uniqueness enforcement, --replace-all, --dry-run, escape sequences, and --no-match-case - Align error messages and output format with ox-cli - Fix upstream test references to renamed struct fields
f759477 to
aef903e
Compare
|
Thanks for the thoughtful response Your PR is really interesting. I might look at adding it to another tool I'm working on. I was trying to make add commands agents need to work effectively docs read is entirely new — sed doesn't cover reading at all. Pagination (--offset/--limit) I think docs edit complements sed rather than competing with it — they serve different audiences. edit is the "Find On the consolidation concern — I agree you don't want 5 ways to edit docs. I'd argue edit could replace the existing find-replace hat way the count stays I'm all for reusing code, but I don't see too much scope for this building on top of sed. Edit has to fetch the doc first for uniqueness checking. I've updated the PR description and rebased onto current main. Let me know your thoughts. And thanks for your time! |
Summary
gog docs read— reads a Google Doc as plain text with character-based--offsetand--limitfor paging through large documents
gog docs edit— find-and-replace with--old/--newthat requires the match to be unique bydefault, preventing accidental edits (use
--replace-allto override). Adds--dry-run, escape sequences,and
--no-match-case.Motivation
My family uses Google Docs for shared lists and notes, and when I tried using an AI agent to help manage them
via gog, it struggled — there was no structured way to read a doc with pagination or safely edit specific
text. The existing
find-replacereplaces all occurrences with no uniqueness check, which is risky forautomated use.
These commands are modelled on ox-cli (my CLI for editing local Office
documents) so that agents can use a consistent interface across both local and Google Docs.
readgives youplain text with character-based pagination for large documents, and
editrequires a unique match so youdon't accidentally change the wrong thing.
This PR complements #359 (
docs sed) rather than replacing it —editis the simple "Find and Replace" foragents that just need
--old "X" --new "Y", whilesedis the power tool for regex and multi-operationpipelines.
New commands
Test plan
applyCharWindow,countOccurrences,unescapeString)read(plain text, character offset/limit, offset-only, limit-only, offset pastend, JSON output)
edit(unique replacement, not-unique error, not-found error,--replace-all,JSON output,
--dry-run,--dry-runJSON, deletion, escape sequences,--no-match-case)docs_edit_test.gofield references to match renamed struct fields