Skip to content

feat(docs): top-level table-row / table-column / table-merge commands #686

Description

@sebsnyk

Motivation

gog already implements row/column add/delete and cell merge via the gog docs sed brace DSL (|2|[+1,0]/foo/, |2|[1,1:1,3]/merge/, etc.). These are powerful but the syntax overhead is high for one-shot calls in scripts. A user who knows "I want to add a row at the end of the second table" should not have to learn the regex address syntax.

The implementation already exists in internal/cmd/docs_sed_table_ops.go (InsertTableRow / DeleteTableRow / InsertTableColumn / DeleteTableColumn / MergeTableCells / UnmergeTableCells emitted from the sed path). Lifting them into top-level commands is mostly a CLI surface change.

Repro

# Today (works but unwieldy):
gog docs sed <DOC_ID> '|2|[+1,0]//'                  # append empty row to 2nd table
gog docs sed <DOC_ID> '|2|[1,1:1,3]/merge/'           # merge top row cols 1-3

# Wanted:
gog docs table-row insert <DOC_ID> --table=2 --at=end
gog docs table-merge <DOC_ID> --table=2 --range=1,1:1,3

Proposed surface

gog docs table-row insert <docId> --table=<idx|header-text> --at=<n|end> [--values-json=...]
gog docs table-row delete <docId> --table=<idx|header-text> --row=N
gog docs table-column insert <docId> --table=<idx|header-text> --at=<n|end>
gog docs table-column delete <docId> --table=<idx|header-text> --col=N
gog docs table-merge <docId> --table=<idx|header-text> --range=r1,c1:r2,c2
gog docs table-unmerge <docId> --table=<idx|header-text> --cell=r,c

--table=<header-text> mode: resolves to the table whose first-row-first-cell text matches verbatim (Docs API has no native "table label" — this is the most stable proxy in practice).

All commands map to single batchUpdate requests; the brace-DSL implementation can be lifted into a shared helper.

Acceptance criteria

  • 1:1 behavioural parity with the corresponding sed brace expressions.
  • --table=<header-text> resolves the table by verbatim first-cell text; ambiguity errors out.
  • Index-based --table=N matches the sed convention (1-based, negative from end, * for all).
  • Returns the index of the new row/column or the merged range in JSON mode.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper 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.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions