[BREAKGLASS] Google Suite CLI: Gmail, GCal, GDrive, GContacts. https://gogcli.sh/
Go to file
2025-12-24 18:25:18 +01:00
.github/workflows ci: allow backfilling existing tags 2025-12-20 00:59:53 +01:00
cmd/gog test: raise coverage above 75% 2025-12-17 21:53:52 +01:00
docs docs(gmail): document --body-html 2025-12-24 18:25:18 +01:00
internal feat(gmail): restore reply-to-address header 2025-12-24 18:25:18 +01:00
scripts Add pnpm gog build+run shortcut 2025-12-12 14:24:29 +00:00
.gitignore chore: ignore local gog binary 2025-12-24 17:15:21 +01:00
.golangci.yml Unify Google CLI with auth, services, and CI 2025-12-12 14:18:38 +00:00
.goreleaser.yaml ci: add goreleaser release workflow 2025-12-20 00:54:52 +01:00
CHANGELOG.md fix(gmail): harden base64url decoding 2025-12-24 18:01:59 +01:00
go.mod Deps: bump to latest 2025-12-12 15:33:49 +00:00
go.sum Deps: bump to latest 2025-12-12 15:33:49 +00:00
LICENSE Initial commit 2025-12-12 12:36:45 +00:00
Makefile make: add build target 2025-12-24 17:17:47 +01:00
package.json Add pnpm gog build+run shortcut 2025-12-12 14:24:29 +00:00
README.md docs(gmail): document --body-html 2025-12-24 18:25:18 +01:00

📮 gog — Google in your terminal

Minimal Google CLI in Go for:

  • Gmail
  • Calendar
  • Drive
  • Contacts (People API)
  • People (profile / people/me)

Install / Build

Install via Homebrew (tap):

  • brew install steipete/tap/gogcli

Build locally:

  • make

Run:

  • ./bin/gog --help

Setup (OAuth)

Before adding an account you need OAuth2 credentials from Google Cloud Console:

  1. Create a project (or select an existing one): https://console.cloud.google.com/projectcreate
  2. Enable the APIs you need:
  3. Set app name / branding (OAuth consent screen): https://console.cloud.google.com/auth/branding
  4. If your app is in “Testing”, add test users (all Google accounts youll use with gog): https://console.cloud.google.com/auth/audience
  5. Create an OAuth client: https://console.cloud.google.com/auth/clients
    • Click “Create Client”
    • Application type: “Desktop app”
    • Download the JSON file (usually named like client_secret_....apps.googleusercontent.com.json)

Then:

  • Store the downloaded client JSON (no renaming required):
    • gog auth credentials ~/Downloads/client_secret_....json
  • Authorize your account (refresh token stored in OS keychain via github.com/99designs/keyring):
    • gog auth add you@gmail.com

Notes:

  • If no OS keychain backend is available (e.g. Linux/WSL/container), keyring can fall back to an encrypted on-disk store and may prompt for a password; for non-interactive runs set GOG_KEYRING_PASSWORD.
  • Default is --services all (gmail, calendar, drive, contacts).
  • To request fewer scopes: gog auth add you@gmail.com --services drive,calendar.
  • If you add services later and Google doesnt return a refresh token, re-run with --force-consent.
  • gog auth add ... overwrites the stored token for that email.

Accounts

Most API commands require an account selection:

  • --account you@gmail.com
  • or set GOG_ACCOUNT=you@gmail.com to avoid repeating the flag.

List configured accounts:

  • gog auth list

Output (Parseable)

  • --output=text (default): plain text on stdout (lists are tab-separated).
  • --output=json: JSON on stdout (best for scripting).
  • Human-facing hints/progress go to stderr.
  • Colors are enabled only in rich TTY output and are disabled automatically for JSON.

Useful pattern:

  • gog --output=json ... | jq .

If you use pnpm, see the shortcut section for pnpm -s (silent) to keep stdout clean.

Examples

Drive:

  • gog drive ls --max 20
  • gog drive search "invoice" --max 20
  • gog drive get <fileId>
  • gog drive download <fileId>
  • gog drive upload ./path/to/file --folder <folderId>

Calendar:

  • gog calendar calendars
  • gog calendar events <calendarId> --from 2025-12-08T00:00:00+01:00 --to 2025-12-15T00:00:00+01:00 --max 250
  • gog calendar event <calendarId> <eventId>
  • gog calendar respond <calendarId> <eventId> --status accepted

Gmail:

  • gog gmail search 'newer_than:7d' --max 10
  • gog gmail thread <threadId>
  • gog gmail get <messageId> --format metadata
  • gog gmail attachment <messageId> <attachmentId> --out ./attachment.bin
  • gog gmail labels list
  • gog gmail labels get INBOX --output=json (includes counts)
  • gog gmail send --to a@b.com --subject "Hi" --body "Plain fallback" --body-html "<p>Hello</p>"

Contacts:

  • gog contacts list --max 50
  • gog contacts search "Ada" --max 50
  • gog contacts get people/...
  • gog contacts other list --max 50

Workspace directory (requires Google Workspace account; @gmail.com wont work):

  • gog contacts directory list --max 50
  • gog contacts directory search "Jane" --max 50

People:

  • gog people me

Environment

  • GOG_ACCOUNT=you@gmail.com (used if --account is omitted)
  • GOG_COLOR=auto|always|never (default auto)
  • GOG_OUTPUT=text|json (default text)

Development

Pinned tools (installed into .tools/):

  • Format: make fmt (goimports + gofumpt)
  • Lint: make lint (golangci-lint)
  • Test: make test

CI runs format checks, tests, and lint on push/PR.

pnpm gog shortcut

Build + run in one step:

  • pnpm gog auth add you@gmail.com

For clean stdout when scripting:

  • pnpm -s gog --output=json gmail search "from:me" | jq .

Credits

This project is inspired by Mario Zechners original CLIs: