-
Notifications
You must be signed in to change notification settings - Fork 621
feat(docs): add --at <text> anchor to insert / delete / update / insert-person / insert-page-break #683
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Motivation
gog docs insert-image --at <placeholder>already follows the "anchor by text" pattern and is much friendlier than--index=N. The sibling commandsinsert,delete,update,insert-person,insert-page-breakall still require numeric indices, forcing callers into the samedocs rawwalk pattern over and over.Once
find-range(#682) lands, these can be implemented as thin wrappers.Depends on
find-rangeprimitive —--at <text>resolves the anchor by calling the same range-finder. Without feat(docs): add find-range primitive that maps text to Document index ranges #682 the implementation reproduces the walk-and-index logic per command; with feat(docs): add find-range primitive that maps text to Document index ranges #682 each--atis a one-call resolver into the existing index-based path.Verified against current source (v0.21.x):
docs_insert_page_break.goexposes--index+--at-endonly; no--at <text>.docs_format.goflag set is bold/italic/underline/strike/font-family/font-size/text-color/bg-color/alignment/line-spacing/heading-level/named-style — no text-anchor.docs_insert_image.gois the only command withname:"at".Repro
Today, to insert a Person chip at a specific name occurrence inside a doc body, a script has to:
gog docs rawand walk for the matching textRun.gog docs delete --start=S --end=Eto remove the existing run.gog docs insert-person --email=... --index=S.Three calls per chip, with the indices recomputed in reverse-document order to avoid drift.
Proposed surface
Add the following flags to each command:
Per command behaviour:
delete --at <text>— delete the matched range. Mutually exclusive with--start/--end.insert --at <text>— insert at the start index of the match (does not replace; for replace, useupdate).update --at <text>— replace the matched range with--text/--filecontent. Mutually exclusive with--index/--replace-range.insert-person --at <text>— atomic delete-and-insert-chip in one batchUpdate.insert-page-break --at <text>— insert at the start index of the match.When the match is ambiguous and
--occurrenceis not set, exit non-zero with a hint listing all occurrences.Acceptance criteria
--at <text>and the result is identical to the current--index/--start/--endform when fed the resolved range.--occurrenceproduce an error before mutating.insert-person --atis atomic (single batchUpdate request bundling DeleteContentRange + the InsertText/InsertPerson sequence), so concurrent writers cannot see an intermediate state.References
gog docs insert-image --at <text>ininternal/cmd/docs_insert_image.go