gogcli
Command-line interface for Google Workspace and consumer Google services. Binary name: gog.
First Step: Check Account
Run gog auth list at the start of every session to check available accounts:
gog auth list
Account selection:
--account <email|alias> flag on any command
GOG_ACCOUNT environment variable sets default
- If only one account is stored, it is used automatically
List configured aliases:
gog auth alias list
Flag Placement
Always place flags after the subcommand, not between gog and the command group. This ensures command prefix matching works correctly for permissions.
# Correct:
gog gmail search 'is:unread' --account work --json
gog calendar events --today --account personal
# Wrong:
gog --account work gmail search 'is:unread'
Output Modes
Always use --json for search and list commands. The default table output trims columns to fit the terminal, losing data. JSON returns complete results.
gog gmail search 'newer_than:7d' --json # JSON (complete data)
gog gmail search 'newer_than:7d' --json --results-only # JSON without envelope
gog gmail search 'newer_than:7d' --json --select=id,subject # Select fields
gog gmail search 'newer_than:7d' --plain # Stable TSV (for piping)
gog gmail search 'newer_than:7d' # Rich TTY (truncates columns)
Global Flags
| Flag |
Description |
--account |
Account email or alias |
--json |
JSON output |
--plain |
TSV output |
--results-only |
Drop envelope fields in JSON |
--select |
Select fields in JSON output |
--dry-run |
Print intended actions, don't execute |
--force |
Skip confirmations |
--no-input |
Never prompt (CI mode) |
--verbose |
Debug logging |
Discovering Flags
This skill covers the most common usage patterns. For full flag details on any command, run --help:
gog gmail send --help
gog calendar create --help
gog drive upload --help
Gmail Search
Search Threads
gog gmail search 'newer_than:7d' # Last 7 days
gog gmail search 'from:alice@example.com' # From sender
gog gmail search 'is:unread' --max 20 # Unread, limit 20
gog gmail search 'has:attachment newer_than:30d' # With attachments
gog gmail search 'subject:invoice' --all # All pages
gog gmail search 'in:sent newer_than:1d' --json # JSON output
gog gmail search 'label:important' --oldest # Show first message date
gog gmail search 'query' --fail-empty # Exit code 3 if no results
Key flags: --max (default 10), --all (all pages), --fail-empty (exit code 3 if no results)
Search Messages (individual messages, not threads)
gog gmail messages search 'newer_than:7d' # Message-level results
gog gmail messages search 'from:me' --include-body # Include message body
gog gmail messages search 'is:unread' --max 50 --json
Key additional flag: --include-body (includes decoded message body in output)
Read Thread / Message
gog gmail thread get <threadId> # Full thread with all messages
gog gmail thread get <threadId> --full # Show full message bodies
gog gmail thread get <threadId> --download # Download attachments
gog gmail thread get <threadId> --download --out-dir ./attachments
gog gmail get <messageId> # Single message
gog gmail get <messageId> --format metadata # Metadata only
gog gmail url <threadId> # Print Gmail web URL
Calendar Events
List Events
gog calendar events # Primary calendar (default)
gog calendar events --today # Today only
gog calendar events --tomorrow # Tomorrow only
gog calendar events --week # This week (Mon-Sun)
gog calendar events --days 3 # Next 3 days
gog calendar events --from today --to friday # Relative dates
gog calendar events --from 2025-01-01 --to 2025-01-08 # Absolute dates
gog calendar events --all # All calendars
gog calendar events --weekday # Include day-of-week columns
gog calendar events <calendarId> --today # Specific calendar
gog calendar events --query "standup" # Free text search
Run gog calendar events --help for full flag list.
Search Events
gog calendar search "meeting" --today
gog calendar search "standup" --days 30
gog calendar search "quarterly" --from 2025-01-01 --to 2025-03-31 --max 50
Get Single Event
gog calendar event <calendarId> <eventId>
gog calendar event <calendarId> <eventId> --json # JSON with timezone info
List Calendars
gog calendar calendars
Drive Search
List Files
gog drive ls # Root folder (default max 20)
gog drive ls --parent <folderId> # Specific folder
gog drive ls --max 50 # More results
gog drive ls --no-all-drives # My Drive only (excludes shared)
gog drive ls --query "mimeType='application/pdf'" # Drive query filter
Key flags: --max (default 20), --parent (folder ID), --no-all-drives (My Drive only)
Search Files
gog drive search "invoice" # Full-text search
gog drive search "budget report" --max 50
gog drive search "mimeType = 'application/pdf'" --raw-query # Drive query language
gog drive search "quarterly" --no-all-drives # My Drive only
Key flags: --max (default 20), --raw-query (use Drive query language directly)
Get / Download
gog drive get <fileId> # File metadata (check mimeType)
gog drive download <fileId> --format md --out /tmp/gdoc-fileid.md # Export Google Doc as markdown
gog drive download <fileId> --format pdf --out /tmp/gdoc-fileid.pdf # Export as PDF
gog drive url <fileId> # Print web URL
Format options by file type:
- Google Docs:
md (best for reading), pdf, docx, txt
- Google Sheets:
csv, xlsx, pdf
- Google Slides:
pptx, pdf
- Google Drawings:
png, pdf
When you need to read a Google Doc's content, prefer --format md. It preserves headings, bold/italic, links, tables, and lists. Plain text (txt) strips all formatting.
Sheets Read
To read a spreadsheet, first get sheet names with metadata, then read with an A1 range:
gog sheets metadata <spreadsheetId> # Discover sheet names
gog sheets get <spreadsheetId> 'SheetName!A1:Z100' # Read values (range required)
gog sheets get <spreadsheetId> 'SheetName!A:Z' # All rows in columns A-Z
The range must use A1 notation (SheetName!A1:B10). A bare sheet name will fail. Use gog sheets get, not gog sheets read.
Command Groups
| Group |
Description |
gmail |
Gmail operations |
calendar |
Google Calendar |
drive |
Google Drive |
docs |
Google Docs |
slides |
Google Slides |
sheets |
Google Sheets |
forms |
Google Forms |
contacts |
Google Contacts |
tasks |
Google Tasks |
people |
Google People |
chat |
Google Chat (Workspace only) |
appscript |
Google Apps Script |
auth |
Auth and credentials |
config |
Configuration |
Always use full command names (e.g. gog gmail send, not gog send). Always place flags after the full command path (e.g. gog gmail search 'query' --account work, not gog --account work gmail search 'query'). Run gog <group> --help for full subcommand list.
Additional Resources
Reference Files
For detailed command references beyond search/read operations, consult:
- references/gmail.md - Send, drafts, labels, thread modify, batch, filters, settings, tracking, watch
- references/calendar.md - Create, update, delete, respond, freebusy, conflicts, team, focus-time, OOO, working-location
- references/drive.md - Upload, mkdir, move, rename, delete, share, permissions, copy, comments
- references/docs.md - Export (prefer
--format md for reading), cat, create, write, insert, find-replace, tabs, comments
- references/slides.md - Create, export, add/replace slides, notes
- references/sheets.md - Read, write, append, clear, format, notes, metadata, create, copy, export
- references/forms.md - Create forms, get form details, list/get responses
- references/contacts.md - Search, list, create, update, delete contacts, directory, other contacts
- references/tasks.md - Task lists, add, update, done, undo, delete, clear
- references/people.md - Profile (me), get user, search, relations
- references/auth-config.md - Auth commands, multi-account, aliases, keyring, service accounts, config, env vars
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: gogcli-33description: CLI for querying Google Workspace and consumer Google services (Gmail, Calendar, Drive, Docs, Sheets, Slides, Contacts, Tasks, Forms, Chat, People, Apps Script). Use when working with Google services to search email, manage calendar events, upload/download Drive files, read/write Sheets, send emails, manage contacts or tasks, or any Google API operation from the terminal. Triggered by requests involving Google data, Gmail, Google Calendar, Google Drive, Google Docs, Google Sheets, or Google Tasks. Use when this capability is needed.4---56# gogcli78Command-line interface for Google Workspace and consumer Google services. Binary name: `gog`.910## First Step: Check Account1112**Run `gog auth list` at the start of every session** to check available accounts:1314```bash15gog auth list16```1718Account selection:19- `--account <email|alias>` flag on any command20- `GOG_ACCOUNT` environment variable sets default21- If only one account is stored, it is used automatically2223List configured aliases:2425```bash26gog auth alias list27```2829## Flag Placement3031**Always place flags after the subcommand**, not between `gog` and the command group. This ensures command prefix matching works correctly for permissions.3233```bash34# Correct:35gog gmail search 'is:unread' --account work --json36gog calendar events --today --account personal3738# Wrong:39gog --account work gmail search 'is:unread'40```4142## Output Modes4344**Always use `--json` for search and list commands.** The default table output trims columns to fit the terminal, losing data. JSON returns complete results.4546```bash47gog gmail search 'newer_than:7d' --json # JSON (complete data)48gog gmail search 'newer_than:7d' --json --results-only # JSON without envelope49gog gmail search 'newer_than:7d' --json --select=id,subject # Select fields50gog gmail search 'newer_than:7d' --plain # Stable TSV (for piping)51gog gmail search 'newer_than:7d' # Rich TTY (truncates columns)52```5354## Global Flags5556| Flag | Description |57|------|-------------|58| `--account` | Account email or alias |59| `--json` | JSON output |60| `--plain` | TSV output |61| `--results-only` | Drop envelope fields in JSON |62| `--select` | Select fields in JSON output |63| `--dry-run` | Print intended actions, don't execute |64| `--force` | Skip confirmations |65| `--no-input` | Never prompt (CI mode) |66| `--verbose` | Debug logging |6768## Discovering Flags6970This skill covers the most common usage patterns. For full flag details on any command, run `--help`:7172```bash73gog gmail send --help74gog calendar create --help75gog drive upload --help76```7778## Gmail Search7980### Search Threads8182```bash83gog gmail search 'newer_than:7d' # Last 7 days84gog gmail search 'from:alice@example.com' # From sender85gog gmail search 'is:unread' --max 20 # Unread, limit 2086gog gmail search 'has:attachment newer_than:30d' # With attachments87gog gmail search 'subject:invoice' --all # All pages88gog gmail search 'in:sent newer_than:1d' --json # JSON output89gog gmail search 'label:important' --oldest # Show first message date90gog gmail search 'query' --fail-empty # Exit code 3 if no results91```9293Key flags: `--max` (default 10), `--all` (all pages), `--fail-empty` (exit code 3 if no results)9495### Search Messages (individual messages, not threads)9697```bash98gog gmail messages search 'newer_than:7d' # Message-level results99gog gmail messages search 'from:me' --include-body # Include message body100gog gmail messages search 'is:unread' --max 50 --json101```102103Key additional flag: `--include-body` (includes decoded message body in output)104105### Read Thread / Message106107```bash108gog gmail thread get <threadId> # Full thread with all messages109gog gmail thread get <threadId> --full # Show full message bodies110gog gmail thread get <threadId> --download # Download attachments111gog gmail thread get <threadId> --download --out-dir ./attachments112gog gmail get <messageId> # Single message113gog gmail get <messageId> --format metadata # Metadata only114gog gmail url <threadId> # Print Gmail web URL115```116117## Calendar Events118119### List Events120121```bash122gog calendar events # Primary calendar (default)123gog calendar events --today # Today only124gog calendar events --tomorrow # Tomorrow only125gog calendar events --week # This week (Mon-Sun)126gog calendar events --days 3 # Next 3 days127gog calendar events --from today --to friday # Relative dates128gog calendar events --from 2025-01-01 --to 2025-01-08 # Absolute dates129gog calendar events --all # All calendars130gog calendar events --weekday # Include day-of-week columns131gog calendar events <calendarId> --today # Specific calendar132gog calendar events --query "standup" # Free text search133```134135Run `gog calendar events --help` for full flag list.136137### Search Events138139```bash140gog calendar search "meeting" --today141gog calendar search "standup" --days 30142gog calendar search "quarterly" --from 2025-01-01 --to 2025-03-31 --max 50143```144145### Get Single Event146147```bash148gog calendar event <calendarId> <eventId>149gog calendar event <calendarId> <eventId> --json # JSON with timezone info150```151152### List Calendars153154```bash155gog calendar calendars156```157158## Drive Search159160### List Files161162```bash163gog drive ls # Root folder (default max 20)164gog drive ls --parent <folderId> # Specific folder165gog drive ls --max 50 # More results166gog drive ls --no-all-drives # My Drive only (excludes shared)167gog drive ls --query "mimeType='application/pdf'" # Drive query filter168```169170Key flags: `--max` (default 20), `--parent` (folder ID), `--no-all-drives` (My Drive only)171172### Search Files173174```bash175gog drive search "invoice" # Full-text search176gog drive search "budget report" --max 50177gog drive search "mimeType = 'application/pdf'" --raw-query # Drive query language178gog drive search "quarterly" --no-all-drives # My Drive only179```180181Key flags: `--max` (default 20), `--raw-query` (use Drive query language directly)182183### Get / Download184185```bash186gog drive get <fileId> # File metadata (check mimeType)187gog drive download <fileId> --format md --out /tmp/gdoc-fileid.md # Export Google Doc as markdown188gog drive download <fileId> --format pdf --out /tmp/gdoc-fileid.pdf # Export as PDF189gog drive url <fileId> # Print web URL190```191192Format options by file type:193- **Google Docs:** `md` (best for reading), `pdf`, `docx`, `txt`194- **Google Sheets:** `csv`, `xlsx`, `pdf`195- **Google Slides:** `pptx`, `pdf`196- **Google Drawings:** `png`, `pdf`197198**When you need to read a Google Doc's content, prefer `--format md`.** It preserves headings, bold/italic, links, tables, and lists. Plain text (`txt`) strips all formatting.199200## Sheets Read201202To read a spreadsheet, first get sheet names with `metadata`, then read with an A1 range:203204```bash205gog sheets metadata <spreadsheetId> # Discover sheet names206gog sheets get <spreadsheetId> 'SheetName!A1:Z100' # Read values (range required)207gog sheets get <spreadsheetId> 'SheetName!A:Z' # All rows in columns A-Z208```209210The range must use A1 notation (`SheetName!A1:B10`). A bare sheet name will fail. Use `gog sheets get`, not `gog sheets read`.211212## Command Groups213214| Group | Description |215|-------|-------------|216| `gmail` | Gmail operations |217| `calendar` | Google Calendar |218| `drive` | Google Drive |219| `docs` | Google Docs |220| `slides` | Google Slides |221| `sheets` | Google Sheets |222| `forms` | Google Forms |223| `contacts` | Google Contacts |224| `tasks` | Google Tasks |225| `people` | Google People |226| `chat` | Google Chat (Workspace only) |227| `appscript` | Google Apps Script |228| `auth` | Auth and credentials |229| `config` | Configuration |230231Always use full command names (e.g. `gog gmail send`, not `gog send`). Always place flags after the full command path (e.g. `gog gmail search 'query' --account work`, not `gog --account work gmail search 'query'`). Run `gog <group> --help` for full subcommand list.232233## Additional Resources234235### Reference Files236237For detailed command references beyond search/read operations, consult:238239- **[references/gmail.md](references/gmail.md)** - Send, drafts, labels, thread modify, batch, filters, settings, tracking, watch240- **[references/calendar.md](references/calendar.md)** - Create, update, delete, respond, freebusy, conflicts, team, focus-time, OOO, working-location241- **[references/drive.md](references/drive.md)** - Upload, mkdir, move, rename, delete, share, permissions, copy, comments242- **[references/docs.md](references/docs.md)** - Export (prefer `--format md` for reading), cat, create, write, insert, find-replace, tabs, comments243- **[references/slides.md](references/slides.md)** - Create, export, add/replace slides, notes244- **[references/sheets.md](references/sheets.md)** - Read, write, append, clear, format, notes, metadata, create, copy, export245- **[references/forms.md](references/forms.md)** - Create forms, get form details, list/get responses246- **[references/contacts.md](references/contacts.md)** - Search, list, create, update, delete contacts, directory, other contacts247- **[references/tasks.md](references/tasks.md)** - Task lists, add, update, done, undo, delete, clear248- **[references/people.md](references/people.md)** - Profile (me), get user, search, relations249- **[references/auth-config.md](references/auth-config.md)** - Auth commands, multi-account, aliases, keyring, service accounts, config, env vars250251---252> Converted and distributed by [TomeVault](https://tomevault.io/claim/fprochazka) — claim your Tome and manage your conversions.253<!-- tomevault:4.0:skill_md:2026-04-13 -->