Skip to content

Commit e1be268

Browse files
authored
feat(sheets): add data validation commands (#728)
1 parent b34e303 commit e1be268

21 files changed

Lines changed: 3355 additions & 54 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- Sheets: add `sheets validation` get/set/clear commands for dropdown, checkbox, number, date, range, and custom-formula rules, and preserve table-managed dropdowns during validation-only copy/paste. (#710) — thanks @chrischall.
78
- Docs: add `docs named-range` create/list/delete/replace commands for durable, tab-aware document anchors. (#692) — thanks @sebsnyk.
89
- Gmail: report attached filenames and byte sizes in JSON results for send and draft create/update. (#716) — thanks @chrischall.
910
- Gmail: add `gmail watch pull` for Pub/Sub pull subscription consumers with hook retry support. (#700) — thanks @joshp123.

docs/commands.generated.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ Generated from `gog schema --json`.
545545
- [`gog sheets (sheet) unmerge <spreadsheetId> <range>`](commands/gog-sheets-unmerge.md) - Unmerge cells in a range
546546
- [`gog sheets (sheet) update (edit,set) <spreadsheetId> <range> [<values> ...] [flags]`](commands/gog-sheets-update.md) - Update values in a range
547547
- [`gog sheets (sheet) update-note (set-note) <spreadsheetId> <range> [flags]`](commands/gog-sheets-update-note.md) - Set or clear a cell note
548+
- [`gog sheets (sheet) validation (data-validation,validations) <command>`](commands/gog-sheets-validation.md) - Manage cell data validation rules
549+
- [`gog sheets (sheet) validation (data-validation,validations) clear (delete,remove,rm) <spreadsheetId> <range> [flags]`](commands/gog-sheets-validation-clear.md) - Clear data validation rules; fully selected table dropdown columns become text columns
550+
- [`gog sheets (sheet) validation (data-validation,validations) get (list,show) <spreadsheetId> <range>`](commands/gog-sheets-validation-get.md) - Get data validation rules from a range
551+
- [`gog sheets (sheet) validation (data-validation,validations) set (add,create) --type=STRING <spreadsheetId> <range> [flags]`](commands/gog-sheets-validation-set.md) - Set a data validation rule on a range
548552
- [`gog sites (site) <command> [flags]`](commands/gog-sites.md) - Google Sites (Drive-backed)
549553
- [`gog sites (site) get (info,show) <siteId> [flags]`](commands/gog-sites-get.md) - Get Google Site metadata
550554
- [`gog sites (site) list (ls) [flags]`](commands/gog-sites-list.md) - List Google Sites visible in Drive

docs/commands/README.md

Lines changed: 5 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: 602.
5+
Generated pages: 606.
66

77
## Top-level Commands
88

@@ -597,6 +597,10 @@ Generated pages: 602.
597597
- [gog sheets unmerge](gog-sheets-unmerge.md) - Unmerge cells in a range
598598
- [gog sheets update](gog-sheets-update.md) - Update values in a range
599599
- [gog sheets update-note](gog-sheets-update-note.md) - Set or clear a cell note
600+
- [gog sheets validation](gog-sheets-validation.md) - Manage cell data validation rules
601+
- [gog sheets validation clear](gog-sheets-validation-clear.md) - Clear data validation rules; fully selected table dropdown columns become text columns
602+
- [gog sheets validation get](gog-sheets-validation-get.md) - Get data validation rules from a range
603+
- [gog sheets validation set](gog-sheets-validation-set.md) - Set a data validation rule on a range
600604
- [gog sites](gog-sites.md) - Google Sites (Drive-backed)
601605
- [gog sites get](gog-sites-get.md) - Get Google Site metadata
602606
- [gog sites list](gog-sites-list.md) - List Google Sites visible in Drive
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# `gog sheets validation clear`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Clear data validation rules; fully selected table dropdown columns become text columns
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) validation (data-validation,validations) clear (delete,remove,rm) <spreadsheetId> <range> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets validation](gog-sheets-validation.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/drivelabels/docs/slides/contacts/tasks/people/sheets/forms/sites/appscript/analytics/searchconsole/youtube/photos) |
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 command prefixes; dot paths allowed (restricts CLI) |
28+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
29+
| `--filtered-rows-included` | `bool` | | Clear rules from filtered rows too; required for table-managed dropdown columns |
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+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
37+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
38+
| `--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. |
39+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
40+
| `--version` | `kong.VersionFlag` | | Print version and exit |
41+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
42+
43+
## See Also
44+
45+
- [gog sheets validation](gog-sheets-validation.md)
46+
- [Command index](README.md)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# `gog sheets validation get`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Get data validation rules from a range
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) validation (data-validation,validations) get (list,show) <spreadsheetId> <range>
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets validation](gog-sheets-validation.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/drivelabels/docs/slides/contacts/tasks/people/sheets/forms/sites/appscript/analytics/searchconsole/youtube/photos) |
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 command prefixes; dot paths allowed (restricts CLI) |
28+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
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+
| `--home` | `string` | | Override gogcli config/data/state/cache root (equivalent to GOG_HOME) |
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+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
39+
| `--version` | `kong.VersionFlag` | | Print version and exit |
40+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
41+
42+
## See Also
43+
44+
- [gog sheets validation](gog-sheets-validation.md)
45+
- [Command index](README.md)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# `gog sheets validation set`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Set a data validation rule on a range
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) validation (data-validation,validations) set (add,create) --type=STRING <spreadsheetId> <range> [flags]
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets validation](gog-sheets-validation.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/drivelabels/docs/slides/contacts/tasks/people/sheets/forms/sites/appscript/analytics/searchconsole/youtube/photos) |
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 command prefixes; dot paths allowed (restricts CLI) |
28+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
29+
| `--filtered-rows-included` | `bool` | | Apply the rule to filtered rows; required for table-managed dropdown columns |
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+
| `--input-message` | `string` | | Message shown when the cell is selected |
35+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
36+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
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+
| `--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. |
40+
| `--show-custom-ui` | `bool` | true | Show dropdown or checkbox UI where supported |
41+
| `--strict` | `bool` | | Reject invalid input instead of showing a warning |
42+
| `--type` | `string` | | Condition type (e.g. ONE_OF_LIST, ONE_OF_RANGE, NUMBER_BETWEEN, DATE_AFTER, BOOLEAN) |
43+
| `--value` | `[]string` | | Condition value; repeat for list or between conditions |
44+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
45+
| `--version` | `kong.VersionFlag` | | Print version and exit |
46+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
47+
48+
## See Also
49+
50+
- [gog sheets validation](gog-sheets-validation.md)
51+
- [Command index](README.md)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# `gog sheets validation`
2+
3+
> Generated from `gog schema --json`. Do not edit this page by hand; run `make docs-commands`.
4+
5+
Manage cell data validation rules
6+
7+
## Usage
8+
9+
```bash
10+
gog sheets (sheet) validation (data-validation,validations) <command>
11+
```
12+
13+
## Parent
14+
15+
- [gog sheets](gog-sheets.md)
16+
17+
## Subcommands
18+
19+
- [gog sheets validation clear](gog-sheets-validation-clear.md) - Clear data validation rules; fully selected table dropdown columns become text columns
20+
- [gog sheets validation get](gog-sheets-validation-get.md) - Get data validation rules from a range
21+
- [gog sheets validation set](gog-sheets-validation-set.md) - Set a data validation rule on 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/drivelabels/docs/slides/contacts/tasks/people/sheets/forms/sites/appscript/analytics/searchconsole/youtube/photos) |
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 command prefixes; dot paths allowed (restricts CLI) |
34+
| `--enable-commands-exact` | `string` | | Comma-separated list of exact enabled commands; dot paths allowed and parent commands do not enable children |
35+
| `-y`<br>`--force`<br>`--assume-yes`<br>`--yes` | `bool` | | Skip confirmations for destructive commands |
36+
| `--gmail-no-send` | `bool` | false | Block Gmail send operations (agent safety) |
37+
| `-h`<br>`--help` | `kong.helpFlag` | | Show context-sensitive help. |
38+
| `--home` | `string` | | Override gogcli config/data/state/cache root (equivalent to GOG_HOME) |
39+
| `-j`<br>`--json`<br>`--machine` | `bool` | false | Output JSON to stdout (best for scripting) |
40+
| `--no-input`<br>`--non-interactive`<br>`--noninteractive` | `bool` | | Never prompt; fail instead (useful for CI) |
41+
| `-p`<br>`--plain`<br>`--tsv` | `bool` | false | Output stable, parseable text to stdout (TSV; no colors) |
42+
| `--results-only` | `bool` | | In JSON mode, emit only the primary result (drops envelope fields like nextPageToken) |
43+
| `--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. |
44+
| `-v`<br>`--verbose` | `bool` | | Enable verbose logging |
45+
| `--version` | `kong.VersionFlag` | | Print version and exit |
46+
| `--wrap-untrusted` | `bool` | false | In JSON/raw output, wrap fetched text fields in external untrusted-content markers |
47+
48+
## See Also
49+
50+
- [gog sheets](gog-sheets.md)
51+
- [Command index](README.md)

docs/commands/gog-sheets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ gog sheets (sheet) <command> [flags]
4949
- [gog sheets unmerge](gog-sheets-unmerge.md) - Unmerge cells in a range
5050
- [gog sheets update](gog-sheets-update.md) - Update values in a range
5151
- [gog sheets update-note](gog-sheets-update-note.md) - Set or clear a cell note
52+
- [gog sheets validation](gog-sheets-validation.md) - Manage cell data validation rules
5253

5354
## Flags
5455

internal/cmd/dryrun_e2e_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,16 @@ func TestDryRunE2E_MutatingCommandsSkipAuthAndAPI(t *testing.T) {
581581
args: []string{"sheets", "conditional-format", "clear", "sheet123", "--sheet", "Sheet1", "--all"},
582582
op: "sheets.conditional-format.clear",
583583
},
584+
{
585+
name: "sheets validation set",
586+
args: []string{"sheets", "validation", "set", "sheet123", "Sheet1!A1:A10", "--type", "ONE_OF_LIST", "--value", "one", "--value", "two"},
587+
op: "sheets.validation.set",
588+
},
589+
{
590+
name: "sheets validation clear",
591+
args: []string{"sheets", "validation", "clear", "sheet123", "Sheet1!A1:A10"},
592+
op: "sheets.validation.clear",
593+
},
584594
{
585595
name: "sheets copy",
586596
args: []string{"sheets", "copy", "sheet123", "SmokeSheet"},

internal/cmd/sheets.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import (
1818

1919
var newSheetsService = googleapi.NewSheets
2020

21-
const sheetsDefaultValueInputOption = "USER_ENTERED"
21+
const (
22+
sheetsDefaultValueInputOption = "USER_ENTERED"
23+
sheetsConditionOneOfList = "ONE_OF_LIST"
24+
sheetsTypeDropdown = "DROPDOWN"
25+
sheetsTypeText = "TEXT"
26+
)
2227

2328
// cleanRange removes shell escape sequences from range arguments.
2429
// Some shells escape ! to \! (bash history expansion), which breaks Google Sheets API calls.
@@ -35,6 +40,7 @@ type SheetsCmd struct {
3540
Clear SheetsClearCmd `cmd:"" name:"clear" help:"Clear values in a range"`
3641
Format SheetsFormatCmd `cmd:"" name:"format" help:"Apply cell formatting to a range"`
3742
Conditional SheetsConditionalCmd `cmd:"" name:"conditional-format" aliases:"cf,conditional-formats" help:"Manage conditional formatting rules"`
43+
Validation SheetsValidationCmd `cmd:"" name:"validation" aliases:"data-validation,validations" help:"Manage cell data validation rules"`
3844
Banding SheetsBandingCmd `cmd:"" name:"banding" aliases:"banded-ranges" help:"Manage alternating color banding"`
3945
Merge SheetsMergeCmd `cmd:"" name:"merge" help:"Merge cells in a range"`
4046
Unmerge SheetsUnmergeCmd `cmd:"" name:"unmerge" help:"Unmerge cells in a range"`

0 commit comments

Comments
 (0)