Skip to content

Commit c78e609

Browse files
feat(slides): add native table creation (#837)
Add native Slides table creation and safe zero-based table-cell text insertion and replacement. Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
1 parent 21ca030 commit c78e609

15 files changed

Lines changed: 863 additions & 11 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Slides: allow `insert-image` and `replace-slide` to use public HTTPS image URLs without temporary Drive sharing. (#825) — thanks @sebsnyk.
88
- Slides: add structured element geometry, styled text runs, table-cell content, image source URLs, native presentation metadata, and read-only text location with exact UTF-16 ranges. (#822) — thanks @sebsnyk.
99
- Slides: add range-scoped styling, links, bullets, and object-scoped replacement; `replace-text` now requires explicit `--object`, `--page`, or `--all` scope instead of silently changing the whole deck. (#823, #835) — thanks @sebsnyk.
10+
- Slides: add native table creation and zero-based table-cell targeting for `insert-text`, including atomic cell replacement. (#824, #834) — thanks @sebsnyk.
1011

1112
### Fixed
1213

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ Docs: [Slides from Markdown](docs/slides-markdown.md),
383383
[template replacement](docs/slides-template-replacement.md),
384384
[introspection](docs/slides-introspection.md),
385385
[text editing](docs/slides-text-editing.md),
386+
[tables](docs/slides-tables.md),
386387
[`gog slides`](docs/commands/gog-slides.md),
387388
[`gog forms`](docs/commands/gog-forms.md).
388389

@@ -393,6 +394,8 @@ gog slides read-slide <presentationId> <slideId> --detail --json
393394
gog slides locate <presentationId> "Quarterly revenue" --all --json
394395
gog slides style-text <presentationId> <objectId> --range 0:12 --bold --size 24
395396
gog slides replace-text <presentationId> old new --object <objectId>
397+
gog slides table create <presentationId> <slideId> --rows 2 --cols 3
398+
gog slides insert-text <presentationId> <tableId> "Revenue" --row 0 --col 0 --replace
396399
gog slides insert-image <presentationId> <slideId> chart.png --x 24 --y 24 --width 240
397400
gog slides insert-text <presentationId> <objectId> "New text"
398401
gog forms update <formId> --quiz=true

docs/commands.generated.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,8 @@ Generated from `gog schema --json`.
604604
- [`gog slides (slide) replace-slide <presentationId> <slideId> [<image>] [flags]`](commands/gog-slides-replace-slide.md) - Replace an existing slide image from a local file or public URL
605605
- [`gog slides (slide) replace-text <presentationId> <find> <replacement> [flags]`](commands/gog-slides-replace-text.md) - Find-and-replace text in an explicit object, slide, or presentation scope
606606
- [`gog slides (slide) style-text --range=STRING <presentationId> <objectId> [flags]`](commands/gog-slides-style-text.md) - Apply range-scoped text styling to one page element
607+
- [`gog slides (slide) table <command>`](commands/gog-slides-table.md) - Create and update native tables
608+
- [`gog slides (slide) table create (add) --rows=INT-64 --cols=INT-64 <presentationId> <slideId> [flags]`](commands/gog-slides-table-create.md) - Create an auto-sized native table on a slide
607609
- [`gog slides (slide) thumbnail (thumb) <presentationId> <slideId> [flags]`](commands/gog-slides-thumbnail.md) - Get or download a rendered thumbnail for a slide
608610
- [`gog slides (slide) update-notes <presentationId> <slideId> [flags]`](commands/gog-slides-update-notes.md) - Update speaker notes on an existing slide
609611
- [`gog status (st) [flags]`](commands/gog-status.md) - Show auth/config status (alias for 'auth status')

docs/commands/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Every `gog` command has a generated docs page. The source of truth is the live CLI schema; run `make docs-commands` after changing command names, flags, help text, aliases, or arguments.
44

5-
Generated pages: 650.
5+
Generated pages: 652.
66

77
## Top-level Commands
88

@@ -655,6 +655,8 @@ Generated pages: 650.
655655
- [gog slides replace-slide](gog-slides-replace-slide.md) - Replace an existing slide image from a local file or public URL
656656
- [gog slides replace-text](gog-slides-replace-text.md) - Find-and-replace text in an explicit object, slide, or presentation scope
657657
- [gog slides style-text](gog-slides-style-text.md) - Apply range-scoped text styling to one page element
658+
- [gog slides table](gog-slides-table.md) - Create and update native tables
659+
- [gog slides table create](gog-slides-table-create.md) - Create an auto-sized native table on a slide
658660
- [gog slides thumbnail](gog-slides-thumbnail.md) - Get or download a rendered thumbnail for a slide
659661
- [gog slides update-notes](gog-slides-update-notes.md) - Update speaker notes on an existing slide
660662
- [gog status](gog-status.md) - Show auth/config status (alias for 'auth status')

docs/commands/gog-slides-insert-text.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ gog slides (slide) insert-text <presentationId> <objectId> <text> [flags]
2121
| `--access-token` | `string` | | Use provided access token directly (bypasses stored refresh tokens; token expires in ~1h) |
2222
| `-a`<br>`--account`<br>`--acct` | `string` | | Account email, alias, or auto for authenticated Google API commands |
2323
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
24+
| `--col` | `*int64` | | 0-based table column index for cell-targeted text; requires --row |
2425
| `--color` | `string` | auto | Color output: auto\|always\|never |
2526
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
2627
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
@@ -36,6 +37,7 @@ gog slides (slide) insert-text <presentationId> <objectId> <text> [flags]
3637
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
3738
| `--replace` | `bool` | | Clear existing text in the element before inserting (emits DeleteText + InsertText in the same batch) |
3839
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
40+
| `--row` | `*int64` | | 0-based table row index for cell-targeted text; requires --col |
3941
| `--select`<br>`--pick`<br>`--project` | `string` | | In JSON mode, select comma-separated fields (best-effort; supports dot paths). Desire path: use --fields for most commands. |
4042
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
4143
| `--version` | `kong.VersionFlag` | | Print version and exit |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# `gog slides table create`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Create an auto-sized native table on a slide
6+
7+
## Usage
8+
9+
```bash
10+
gog slides (slide) table create (add) --rows=INT-64 --cols=INT-64 <presentationId> <slideId> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog slides table](gog-slides-table.md)
16+
17+
## Flags
18+
19+
| Flag | Type | Default | Help |
20+
| --- | --- | --- | --- |
21+
| `--access-token` | `string` | | Use provided access token directly (bypasses stored refresh tokens; token expires in ~1h) |
22+
| `-a`<br>`--account`<br>`--acct` | `string` | | Account email, alias, or auto for authenticated Google API commands |
23+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
24+
| `--color` | `string` | auto | Color output: auto\|always\|never |
25+
| `--cols` | `int64` | | Number of table columns (>=1) |
26+
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
27+
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
28+
| `--enable-commands` | `string` | | Comma-separated list of enabled command prefixes; dot paths allowed (restricts CLI) |
29+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
30+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
31+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
32+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
33+
| `--home` | `string` | | Override gogcli config/data/state/cache root (equivalent to GOG_HOME) |
34+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
35+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
36+
| `--object-id` | `string` | | Optional table object ID to assign |
37+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
38+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
39+
| `--rows` | `int64` | | Number of table rows (>=1) |
40+
| `--select`<br>`--pick`<br>`--project` | `string` | | In JSON mode, select comma-separated fields (best-effort; supports dot paths). Desire path: use --fields for most commands. |
41+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
42+
| `--version` | `kong.VersionFlag` | | Print version and exit |
43+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
44+
45+
## See Also
46+
47+
- [gog slides table](gog-slides-table.md)
48+
- [Command index](README.md)

docs/commands/gog-slides-table.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# `gog slides table`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Create and update native tables
6+
7+
## Usage
8+
9+
```bash
10+
gog slides (slide) table <command>
11+
```
12+
13+
## Parent
14+
15+
- [gog slides](gog-slides.md)
16+
17+
## Subcommands
18+
19+
- [gog slides table create](gog-slides-table-create.md) - Create an auto-sized native table on a slide
20+
21+
## Flags
22+
23+
| Flag | Type | Default | Help |
24+
| --- | --- | --- | --- |
25+
| `--access-token` | `string` | | Use provided access token directly (bypasses stored refresh tokens; token expires in ~1h) |
26+
| `-a`<br>`--account`<br>`--acct` | `string` | | Account email, alias, or auto for authenticated Google API commands |
27+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
28+
| `--color` | `string` | auto | Color output: auto\|always\|never |
29+
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
30+
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
31+
| `--enable-commands` | `string` | | Comma-separated list of enabled command prefixes; dot paths allowed (restricts CLI) |
32+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
33+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
34+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
35+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
36+
| `--home` | `string` | | Override gogcli config/data/state/cache root (equivalent to GOG_HOME) |
37+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
38+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
39+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
40+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
41+
| `--select`<br>`--pick`<br>`--project` | `string` | | In JSON mode, select comma-separated fields (best-effort; supports dot paths). Desire path: use --fields for most commands. |
42+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
43+
| `--version` | `kong.VersionFlag` | | Print version and exit |
44+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
45+
46+
## See Also
47+
48+
- [gog slides](gog-slides.md)
49+
- [Command index](README.md)

docs/commands/gog-slides.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ gog slides (slide) <command> [flags]
3535
- [gog slides replace-slide](gog-slides-replace-slide.md) - Replace an existing slide image from a local file or public URL
3636
- [gog slides replace-text](gog-slides-replace-text.md) - Find-and-replace text in an explicit object, slide, or presentation scope
3737
- [gog slides style-text](gog-slides-style-text.md) - Apply range-scoped text styling to one page element
38+
- [gog slides table](gog-slides-table.md) - Create and update native tables
3839
- [gog slides thumbnail](gog-slides-thumbnail.md) - Get or download a rendered thumbnail for a slide
3940
- [gog slides update-notes](gog-slides-update-notes.md) - Update speaker notes on an existing slide
4041

docs/slides-tables.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Slides tables
2+
3+
Create a native table on an existing slide:
4+
5+
```bash
6+
gog slides table create <presentationId> <slideId> --rows 3 --cols 4
7+
```
8+
9+
The command prints the table object ID. Pass `--object-id` to choose a stable ID
10+
when a later script needs to reference the table without parsing the response.
11+
12+
Google Slides chooses a new table's initial size and position. The Slides API
13+
ignores size and transform fields on table creation, so this command does not
14+
expose geometry flags that would report a result the provider does not honor.
15+
16+
## Cell text
17+
18+
Target a cell with zero-based `--row` and `--col` indexes:
19+
20+
```bash
21+
gog slides insert-text <presentationId> <tableId> "Revenue" --row 0 --col 0
22+
gog slides insert-text <presentationId> <tableId> '$1.2M' --row 1 --col 0 --replace
23+
```
24+
25+
`--row` and `--col` must be provided together. `--replace` clears and inserts
26+
within the selected cell in one Slides batch update; it does not alter other
27+
cells. `--insertion-index` selects an index within the cell when appending or
28+
inserting without `--replace`.
29+
30+
Use `--dry-run --json` to inspect the exact Slides `batchUpdate` request without
31+
contacting Google. Use `slides read-slide --detail --json` to verify the table
32+
dimensions, cell coordinates, and text returned by the provider.

internal/cmd/slides.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type SlidesCmd struct {
3131
ReplaceSlide SlidesReplaceSlideCmd `cmd:"" name:"replace-slide" help:"Replace an existing slide image from a local file or public URL"`
3232
InsertImage SlidesInsertImageCmd `cmd:"" name:"insert-image" help:"Insert a local or public image at a position and size"`
3333
InsertText SlidesInsertTextCmd `cmd:"" name:"insert-text" help:"Insert text into an existing page element (shape or table) by objectId"`
34+
Table SlidesTableCmd `cmd:"" name:"table" help:"Create and update native tables"`
3435
StyleText SlidesStyleTextCmd `cmd:"" name:"style-text" help:"Apply range-scoped text styling to one page element"`
3536
Link SlidesLinkCmd `cmd:"" name:"link" help:"Apply a hyperlink to a text range in one page element"`
3637
Bullets SlidesBulletsCmd `cmd:"" name:"bullets" help:"Turn paragraph bullets on or off in one page element"`

0 commit comments

Comments
 (0)