Skip to content

Commit b836495

Browse files
authored
feat(sheets): add conditional formatting and banding
Adds Google Sheets conditional formatting and alternating color banding commands, with force-guarded clears, docs, regression tests, and live Google smoke verification.\n\nCo-authored-by: gobang <50824182+codBang@users.noreply.github.com>
1 parent aa7c0a2 commit b836495

18 files changed

Lines changed: 1495 additions & 2 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Docs: support tab-scoped Markdown append and find-replace flows. (#541) — thanks @donbowman.
1717
- Sheets: add `sheets table append` for appending rows to structured Sheets tables without targeting headers directly.
1818
- Sheets: add header-safe `sheets table clear` for clearing table data rows without touching headers or footers.
19+
- Sheets: add `sheets conditional-format` and `sheets banding` commands for rule-based formatting and alternating color banded ranges. (#378) — thanks @codBang.
1920

2021
### Fixed
2122
- Agent safety: compile baked safety profile policies into generated hash switches so raw allow/deny rule strings are not embedded as patchable YAML. (#540) — thanks @drewburchfield.

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Fast, script-friendly CLI for Gmail, Calendar, Chat, Classroom, Drive, Docs, Sli
1616
- **Drive** - list/search/upload/download files, scope search to folders or shared drives, replace uploads in-place, convert uploads (including Markdown to Google Doc), manage permissions/comments, organize folders, and list shared drives
1717
- **Contacts** - search/create/update contacts, including addresses, relations, org/title metadata, custom fields, Workspace directory, and other contacts
1818
- **Tasks** - manage tasklists and tasks: get/create/add/update/done/undo/delete/clear, plus repeat schedule materialization with RRULE aliases
19-
- **Sheets** - read/write/update spreadsheets, insert rows/cols, manage tabs, named ranges, and Sheets tables, format/merge/freeze/resize cells, read/write notes, inspect formats, find/replace text, list links, and create/export sheets
19+
- **Sheets** - read/write/update spreadsheets, insert rows/cols, manage tabs, named ranges, and Sheets tables, format/merge/freeze/resize cells, manage conditional formatting and banding, read/write notes, inspect formats, find/replace text, list links, and create/export sheets
2020
- **Forms** - create/update forms, manage questions, inspect responses, and manage watches
2121
- **Apps Script** - create/get/bind projects, inspect content, and run functions
2222
- **Docs/Slides** - create/copy/export docs/slides, edit Docs by tab title or ID, import Markdown, do richer find-replace, export whole Docs or a single Docs tab, and generate Slides from Markdown or templates
@@ -1379,6 +1379,13 @@ gog sheets resize-columns <spreadsheetId> 'Sheet1!A:C' --auto
13791379
gog sheets resize-rows <spreadsheetId> 'Sheet1!1:10' --height 36
13801380
gog sheets read-format <spreadsheetId> 'Sheet1!A1:B2'
13811381
gog sheets read-format <spreadsheetId> 'Sheet1!A1:B2' --effective
1382+
gog sheets conditional-format add <spreadsheetId> 'Sheet1!A2:C' --type text-eq --expr done --format-json '{"backgroundColor":{"red":0.85,"green":0.94,"blue":0.82}}'
1383+
gog sheets conditional-format list <spreadsheetId>
1384+
gog sheets conditional-format clear <spreadsheetId> --sheet Sheet1 --all --force
1385+
gog sheets banding set <spreadsheetId> 'Sheet1!A1:C20'
1386+
gog sheets banding list <spreadsheetId>
1387+
gog sheets banding clear <spreadsheetId> --sheet Sheet1 --all --force
1388+
# See docs/sheets-formatting.md for conditional format and banding details.
13821389

13831390
# Named ranges
13841391
gog sheets named-ranges <spreadsheetId>

docs/commands.generated.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,21 @@ Generated from `gog schema --json`.
382382
- [`gog sheets (sheet) <command> [flags]`](commands/gog-sheets.md) - Google Sheets
383383
- [`gog sheets (sheet) add-tab (add-sheet) <spreadsheetId> <tabName> [flags]`](commands/gog-sheets-add-tab.md) - Add a new tab/sheet to a spreadsheet
384384
- [`gog sheets (sheet) append (add) <spreadsheetId> <range> [<values> ...] [flags]`](commands/gog-sheets-append.md) - Append values to a range
385+
- [`gog sheets (sheet) banding (banded-ranges) <command>`](commands/gog-sheets-banding.md) - Manage alternating color banding
386+
- [`gog sheets (sheet) banding (banded-ranges) clear (delete,rm,remove) <spreadsheetId> [flags]`](commands/gog-sheets-banding-clear.md) - Remove alternating color banding
387+
- [`gog sheets (sheet) banding (banded-ranges) list <spreadsheetId> [flags]`](commands/gog-sheets-banding-list.md) - List alternating color banded ranges
388+
- [`gog sheets (sheet) banding (banded-ranges) set (add,create) <spreadsheetId> <range> [flags]`](commands/gog-sheets-banding-set.md) - Apply alternating colors to a range
385389
- [`gog sheets (sheet) chart (charts) <command>`](commands/gog-sheets-chart.md) - Manage spreadsheet charts
386390
- [`gog sheets (sheet) chart (charts) create (add,new) --spec-json=STRING <spreadsheetId> [flags]`](commands/gog-sheets-chart-create.md) - Create a chart from a JSON spec
387391
- [`gog sheets (sheet) chart (charts) delete (rm,remove,del) <spreadsheetId> <chartId>`](commands/gog-sheets-chart-delete.md) - Delete a chart
388392
- [`gog sheets (sheet) chart (charts) get (show,info) <spreadsheetId> <chartId>`](commands/gog-sheets-chart-get.md) - Get full chart definition (spec + position)
389393
- [`gog sheets (sheet) chart (charts) list <spreadsheetId>`](commands/gog-sheets-chart-list.md) - List charts in a spreadsheet
390394
- [`gog sheets (sheet) chart (charts) update (edit,set) --spec-json=STRING <spreadsheetId> <chartId>`](commands/gog-sheets-chart-update.md) - Update a chart spec
391395
- [`gog sheets (sheet) clear <spreadsheetId> <range>`](commands/gog-sheets-clear.md) - Clear values in a range
396+
- [`gog sheets (sheet) conditional-format (cf,conditional-formats) <command>`](commands/gog-sheets-conditional-format.md) - Manage conditional formatting rules
397+
- [`gog sheets (sheet) conditional-format (cf,conditional-formats) add (create,new) --type=STRING --format-json=STRING <spreadsheetId> <range> [flags]`](commands/gog-sheets-conditional-format-add.md) - Add a conditional formatting rule
398+
- [`gog sheets (sheet) conditional-format (cf,conditional-formats) clear (delete,rm,remove) --sheet=STRING <spreadsheetId> [flags]`](commands/gog-sheets-conditional-format-clear.md) - Remove conditional formatting rules
399+
- [`gog sheets (sheet) conditional-format (cf,conditional-formats) list <spreadsheetId> [flags]`](commands/gog-sheets-conditional-format-list.md) - List conditional formatting rules
392400
- [`gog sheets (sheet) copy (cp,duplicate) <spreadsheetId> <title> [flags]`](commands/gog-sheets-copy.md) - Copy a Google Sheet
393401
- [`gog sheets (sheet) create (new) <title> [flags]`](commands/gog-sheets-create.md) - Create a new spreadsheet
394402
- [`gog sheets (sheet) delete-tab (delete-sheet) <spreadsheetId> <tabName>`](commands/gog-sheets-delete-tab.md) - Delete a tab/sheet from a spreadsheet (use --force to skip confirmation)

docs/commands/README.md

Lines changed: 9 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: 458.
5+
Generated pages: 466.
66

77
## Top-level Commands
88

@@ -425,13 +425,21 @@ Generated pages: 458.
425425
- [gog sheets](gog-sheets.md) - Google Sheets
426426
- [gog sheets add-tab](gog-sheets-add-tab.md) - Add a new tab/sheet to a spreadsheet
427427
- [gog sheets append](gog-sheets-append.md) - Append values to a range
428+
- [gog sheets banding](gog-sheets-banding.md) - Manage alternating color banding
429+
- [gog sheets banding clear](gog-sheets-banding-clear.md) - Remove alternating color banding
430+
- [gog sheets banding list](gog-sheets-banding-list.md) - List alternating color banded ranges
431+
- [gog sheets banding set](gog-sheets-banding-set.md) - Apply alternating colors to a range
428432
- [gog sheets chart](gog-sheets-chart.md) - Manage spreadsheet charts
429433
- [gog sheets chart create](gog-sheets-chart-create.md) - Create a chart from a JSON spec
430434
- [gog sheets chart delete](gog-sheets-chart-delete.md) - Delete a chart
431435
- [gog sheets chart get](gog-sheets-chart-get.md) - Get full chart definition (spec + position)
432436
- [gog sheets chart list](gog-sheets-chart-list.md) - List charts in a spreadsheet
433437
- [gog sheets chart update](gog-sheets-chart-update.md) - Update a chart spec
434438
- [gog sheets clear](gog-sheets-clear.md) - Clear values in a range
439+
- [gog sheets conditional-format](gog-sheets-conditional-format.md) - Manage conditional formatting rules
440+
- [gog sheets conditional-format add](gog-sheets-conditional-format-add.md) - Add a conditional formatting rule
441+
- [gog sheets conditional-format clear](gog-sheets-conditional-format-clear.md) - Remove conditional formatting rules
442+
- [gog sheets conditional-format list](gog-sheets-conditional-format-list.md) - List conditional formatting rules
435443
- [gog sheets copy](gog-sheets-copy.md) - Copy a Google Sheet
436444
- [gog sheets create](gog-sheets-create.md) - Create a new spreadsheet
437445
- [gog sheets delete-tab](gog-sheets-delete-tab.md) - Delete a tab/sheet from a spreadsheet (use --force to skip confirmation)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# `gog sheets banding clear`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Remove alternating color banding
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) banding (banded-ranges) clear (delete,rm,remove) <spreadsheetId> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets banding](gog-sheets-banding.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 for API commands (gmail/calendar/chat/classroom/drive/docs/slides/contacts/tasks/people/sheets/forms/appscript/ads) |
23+
| `--all` | `bool` | | Remove all banding from the sheet |
24+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
25+
| `--color` | `string` | auto | Color output: auto\|always\|never |
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 commands; dot paths allowed (restricts CLI) |
29+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
30+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
31+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
32+
| `--id` | `int64` | | Banded range ID to remove |
33+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
34+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
35+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
36+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
37+
| `--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. |
38+
| `--sheet` | `string` | | Sheet name for --all |
39+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
40+
| `--version` | `kong.VersionFlag` | | Print version and exit |
41+
42+
## See Also
43+
44+
- [gog sheets banding](gog-sheets-banding.md)
45+
- [Command index](README.md)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# `gog sheets banding list`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
List alternating color banded ranges
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) banding (banded-ranges) list <spreadsheetId> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets banding](gog-sheets-banding.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 for API commands (gmail/calendar/chat/classroom/drive/docs/slides/contacts/tasks/people/sheets/forms/appscript/ads) |
23+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
24+
| `--color` | `string` | auto | Color output: auto\|always\|never |
25+
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
26+
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
27+
| `--enable-commands` | `string` | | Comma-separated list of enabled commands; dot paths allowed (restricts CLI) |
28+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
29+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
30+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
31+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
32+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
33+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
34+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
35+
| `--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. |
36+
| `--sheet` | `string` | | Only list banding from this sheet |
37+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
38+
| `--version` | `kong.VersionFlag` | | Print version and exit |
39+
40+
## See Also
41+
42+
- [gog sheets banding](gog-sheets-banding.md)
43+
- [Command index](README.md)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# `gog sheets banding set`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Apply alternating colors to a range
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) banding (banded-ranges) set (add,create) <spreadsheetId> <range> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets banding](gog-sheets-banding.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 for API commands (gmail/calendar/chat/classroom/drive/docs/slides/contacts/tasks/people/sheets/forms/appscript/ads) |
23+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
24+
| `--color` | `string` | auto | Color output: auto\|always\|never |
25+
| `--column-properties-json` | `string` | | Sheets API BandingProperties JSON for column colors |
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 commands; dot paths allowed (restricts CLI) |
29+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
30+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
31+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
32+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
33+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
34+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
35+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
36+
| `--row-properties-json` | `string` | | Sheets API BandingProperties JSON for row colors |
37+
| `--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. |
38+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
39+
| `--version` | `kong.VersionFlag` | | Print version and exit |
40+
41+
## See Also
42+
43+
- [gog sheets banding](gog-sheets-banding.md)
44+
- [Command index](README.md)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# `gog sheets banding`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Manage alternating color banding
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) banding (banded-ranges) <command>
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets](gog-sheets.md)
16+
17+
## Subcommands
18+
19+
- [gog sheets banding clear](gog-sheets-banding-clear.md) - Remove alternating color banding
20+
- [gog sheets banding list](gog-sheets-banding-list.md) - List alternating color banded ranges
21+
- [gog sheets banding set](gog-sheets-banding-set.md) - Apply alternating colors to a range
22+
23+
## Flags
24+
25+
| Flag | Type | Default | Help |
26+
| --- | --- | --- | --- |
27+
| `--access-token` | `string` | | Use provided access token directly (bypasses stored refresh tokens; token expires in ~1h) |
28+
| `-a`<br>`--account`<br>`--acct` | `string` | | Account email for API commands (gmail/calendar/chat/classroom/drive/docs/slides/contacts/tasks/people/sheets/forms/appscript/ads) |
29+
| `--client` | `string` | | OAuth client name (selects stored credentials + token bucket) |
30+
| `--color` | `string` | auto | Color output: auto\|always\|never |
31+
| `--disable-commands` | `string` | | Comma-separated list of disabled commands; dot paths allowed |
32+
| `-n`<br>`--dry-run`<br>`--dryrun`<br>`--noop`<br>`--preview` | `bool` | | Do not make changes; print intended actions and exit successfully |
33+
| `--enable-commands` | `string` | | Comma-separated list of enabled commands; dot paths allowed (restricts CLI) |
34+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
35+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
36+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
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+
45+
## See Also
46+
47+
- [gog sheets](gog-sheets.md)
48+
- [Command index](README.md)

0 commit comments

Comments
 (0)