# 设置
gog gmail autoforward get
gog gmail autoforward enable --email forward@example.com
gog gmail autoforward disable
gog gmail forwarding list
gog gmail forwarding add --email forward@example.com
gog gmail sendas list
gog gmail sendas create --email alias@example.com
gog gmail vacation get
gog gmail vacation enable --subject "Out of office" --message "..."
gog gmail vacation disable
# 委派(G Suite/Workspace)
gog gmail delegates list
gog gmail delegates add --email delegate@example.com
gog gmail delegates remove --email delegate@example.com
# 监控(Pub/Sub push)
gog gmail watch start --topic projects//topics/ --label INBOX
gog gmail watch serve --bind 127.0.0.1 --token --hook-url http://127.0.0.1:18789/hooks/agent
gog gmail watch serve --bind 0.0.0.0 --verify-oidc --oidc-email --hook-url
gog gmail watch serve --bind 127.0.0.1 --token --exclude-labels SPAM,TRASH --hook-url http://127.0.0.1:18789/hooks/agent
gog gmail history --since
```
Gmail watch (Pub/Sub push):
- 创建 Pub/Sub 主题 + 推送订阅(首选 OIDC;共享 Token 可用于开发)。
- 完整流程 + 载荷详情:`docs/watch.md`。
- `watch serve --exclude-labels` 默认为 `SPAM,TRASH`;ID 区分大小写。
### 邮件追踪
追踪收件人何时打开您的电子邮件:
```
# 设置本地跟踪配置(按账户;生成密钥;按照打印的部署步骤操作)
gog gmail track setup --worker-url https://gog-email-tracker..workers.dev
# 发送跟踪
gog gmail send --to recipient@example.com --subject "Hello" --body-html "Hi!
" --track
# 检查打开情况
gog gmail track opens
gog gmail track opens --to recipient@example.com
# 查看状态
gog gmail track status
```
文档:`docs/email-tracking.md`(设置/部署)+ `docs/email-tracking-worker.md`(内部原理)。
**注意:** `--track` 需要恰好 1 个收件人(无 cc/bcc)和 HTML 正文(`--body-html` 或 `--quote`)。使用 `--track-split` 发送带有单独追踪 ID 的按收件人消息。追踪 Worker 默认存储 IP/User-Agent + 粗略地理位置。
### Calendar
```
# 日历
gog calendar calendars
gog calendar acl # List access control rules
gog calendar colors # List available event/calendar colors
gog calendar time --timezone America/New_York
gog calendar users # List workspace users (use email as calendar ID)
# 事件(带有时区感知的时间 flags)
gog calendar events --today # Today's events
gog calendar events --tomorrow # Tomorrow's events
gog calendar events --week # This week (Mon-Sun by default; use --week-start)
gog calendar events --days 3 # Next 3 days
gog calendar events --from today --to friday # Relative dates
gog calendar events --from today --to friday --weekday # Include weekday columns
gog calendar events --from 2025-01-01T00:00:00Z --to 2025-01-08T00:00:00Z
gog calendar events --all # Fetch events from all calendars
gog calendar events --calendars 1,3 # Fetch events from calendar indices (see gog calendar calendars)
gog calendar events --cal Work --cal Personal # Fetch events from calendars by name/ID
gog calendar event
gog calendar get # Alias for event
gog calendar search "meeting" --today
gog calendar search "meeting" --tomorrow
gog calendar search "meeting" --days 365
gog calendar search "meeting" --from 2025-01-01T00:00:00Z --to 2025-01-31T00:00:00Z --max 50
# 除非您设置 --from/--to/--today/--week/--days,否则搜索默认为 30 天前至 90 天后。
# 提示:设置 GOG_CALENDAR_WEEKDAY=1 以默认输出 calendar 事件的 --weekday。
# JSON 事件输出包含时区和本地化时间(对 agents 很有用)。
gog calendar get --json
# {
# "event": {
# "id": "...",
# "summary": "...",
# "startDayOfWeek": "Friday",
# "endDayOfWeek": "Friday",
# "timezone": "America/Los_Angeles",
# "eventTimezone": "America/New_York",
# "startLocal": "2026-01-23T20:45:00-08:00",
# "endLocal": "2026-01-23T22:45:00-08:00",
# "start": { "dateTime": "2026-01-23T23:45:00-05:00" },
# "end": { "dateTime": "2026-01-24T01:45:00-05:00" }
# }
# }
# 团队日历(Google Workspace 需要 Cloud Identity API)
gog calendar team --today # Show team's events for today
gog calendar team --week # Show team's events for the week (use --week-start)
gog calendar team --freebusy # Show only busy/free blocks (faster)
gog calendar team --query "standup" # Filter by event title
# 创建和更新
gog calendar create \
--summary "Meeting" \
--from 2025-01-15T10:00:00Z \
--to 2025-01-15T11:00:00Z
gog calendar create \
--summary "Team Sync" \
--from 2025-01-15T14:00:00Z \
--to 2025-01-15T15:00:00Z \
--attendees "alice@example.com,bob@example.com" \
--location "Zoom"
gog calendar update \
--summary "Updated Meeting" \
--from 2025-01-15T11:00:00Z \
--to 2025-01-15T12:00:00Z
# 创建/更新时发送通知
gog calendar create \
--summary "Team Sync" \
--from 2025-01-15T14:00:00Z \
--to 2025-01-15T15:00:00Z \
--send-updates all
gog calendar update \
--send-updates externalOnly
# 默认:除非您传递 --send-updates,否则不发送与会者通知。
gog calendar delete \
--send-updates all --force
# 重复 + 提醒
gog calendar create \
--summary "Payment" \
--from 2025-02-11T09:00:00-03:00 \
--to 2025-02-11T09:15:00-03:00 \
--rrule "RRULE:FREQ=MONTHLY;BYMONTHDAY=11" \
--reminder "email:3d" \
--reminder "popup:30m"
# 通过 --event-type 设置特殊事件类型(focus-time/out-of-office/working-location)
gog calendar create primary \
--event-type focus-time \
--from 2025-01-15T13:00:00Z \
--to 2025-01-15T14:00:00Z
gog calendar create primary \
--event-type out-of-office \
--from 2025-01-20 \
--to 2025-01-21 \
--all-day
gog calendar create primary \
--event-type working-location \
--working-location-type office \
--working-office-label "HQ" \
--from 2025-01-22 \
--to 2025-01-23
# 专用快捷方式(相同事件类型,更具建议性的默认值)
gog calendar focus-time --from 2025-01-15T13:00:00Z --to 2025-01-15T14:00:00Z
gog calendar out-of-office --from 2025-01-20 --to 2025-01-21 --all-day
gog calendar working-location --type office --office-label "HQ" --from 2025-01-22 --to 2025-01-23
# 添加 attendees 而不替换现有的 attendees/RSVP 状态
gog calendar update \
--add-attendee "alice@example.com,bob@example.com"
gog calendar delete
# 邀请
gog calendar respond --status accepted
gog calendar respond --status declined
gog calendar respond --status tentative
gog calendar respond --status declined --send-updates externalOnly
# 提议新时间(仅限浏览器流程;API 限制)
gog calendar propose-time
gog calendar propose-time --open
gog calendar propose-time --decline --comment "Can we do 5pm?"
# 空闲状态
gog calendar freebusy --calendars "primary,work@example.com" \
--from 2025-01-15T00:00:00Z \
--to 2025-01-16T00:00:00Z
gog calendar conflicts --calendars "primary,work@example.com" \
--today # Today's conflicts
```
### 时间
```
gog time now
gog time now --timezone UTC
```
### Drive
```
# 列表和搜索
gog drive ls --max 20
gog drive ls --parent --max 20
gog drive ls --no-all-drives # Only list from "My Drive"
gog drive search "invoice" --max 20
gog drive search "invoice" --no-all-drives
gog drive search "mimeType = 'application/pdf'" --raw-query
gog drive get # Get file metadata
gog drive url # Print Drive web URL
gog drive copy "Copy Name"
# 上传和下载
gog drive upload ./path/to/file --parent
gog drive upload ./path/to/file --replace # Replace file content in-place (preserves shared link)
gog drive upload ./report.docx --convert
gog drive upload ./chart.png --convert-to sheet
gog drive upload ./report.docx --convert --name report.docx
gog drive download --out ./downloaded.bin
gog drive download --format pdf --out ./exported.pdf # Google Workspace files only
gog drive download --format docx --out ./doc.docx
gog drive download --format pptx --out ./slides.pptx
# 整理
gog drive mkdir "New Folder"
gog drive mkdir "New Folder" --parent
gog drive rename "New Name"
gog drive move --parent
gog drive delete # Move to trash
gog drive delete --permanent # Permanently delete
# 权限
gog drive permissions
gog drive share --to user --email user@example.com --role reader
gog drive share --to user --email user@example.com --role writer
gog drive share --to domain --domain example.com --role reader
gog drive unshare --permission-id
# 共享 drives(Team Drives)
gog drive drives --max 100
```
### Docs / Slides / Sheets
```
# Docs
gog docs info
gog docs cat --max-bytes 10000
gog docs create "My Doc"
gog docs create "My Doc" --file ./doc.md # Import markdown
gog docs copy "My Doc Copy"
gog docs export --format pdf --out ./doc.pdf
gog docs list-tabs
gog docs cat --tab "Notes"
gog docs cat --all-tabs
gog docs update --format markdown --content-file ./doc.md
gog docs write --replace --markdown --file ./doc.md
gog docs find-replace "old" "new"
# Slides
gog slides info
gog slides create "My Deck"
gog slides create-from-markdown "My Deck" --content-file ./slides.md
gog slides copy "My Deck Copy"
gog slides export --format pdf --out ./deck.pdf
gog slides list-slides
gog slides add-slide ./slide.png --notes "Speaker notes"
gog slides update-notes --notes "Updated notes"
gog slides replace-slide ./new-slide.png --notes "New notes"
# Sheets
gog sheets copy "My Sheet Copy"
gog sheets export --format pdf --out ./sheet.pdf
gog sheets format 'Sheet1!A1:B2' --format-json '{"textFormat":{"bold":true}}' --format-fields 'userEnteredFormat.textFormat.bold'
gog sheets insert "Sheet1" rows 2 --count 3
gog sheets notes 'Sheet1!A1:B10'
```
### 联系人
```
# 个人联系人
gog contacts list --max 50
gog contacts search "Ada" --max 50
gog contacts get people/
gog contacts get user@example.com # Get by email
# 其他联系人(您互动过的人)
gog contacts other list --max 50
gog contacts other search "John" --max 50
# 创建和更新
gog contacts create \
--given "John" \
--family "Doe" \
--email "john@example.com" \
--phone "+1234567890"
gog contacts update people/ \
--given "Jane" \
--email "jane@example.com" \
--birthday "1990-05-12" \
--notes "Met at WWDC"
# 通过 JSON 更新(见 docs/contacts-json-update.md)
gog contacts get people/ --json | \
jq '(.contact.urls //= []) | (.contact.urls += [{"value":"obsidian://open?vault=notes&file=People/John%20Doe","type":"profile"}])' | \
gog contacts update people/ --from-file -
gog contacts delete people/
# Workspace 目录(需要 Google Workspace)
gog contacts directory list --max 50
gog contacts directory search "Jane" --max 50
```
### 任务
```
# Task lists
gog tasks lists --max 50
gog tasks lists create
# 列表中的 Tasks
gog tasks list --max 50
gog tasks get
gog tasks add --title "Task title"
gog tasks add --title "Weekly sync" --due 2025-02-01 --repeat weekly --repeat-count 4
gog tasks add --title "Daily standup" --due 2025-02-01 --repeat daily --repeat-until 2025-02-05
gog tasks update --title "New title"
gog tasks done
gog tasks undo
gog tasks delete
gog tasks clear
# 注意:Google Tasks 将截止日期视为仅日期;时间部分可能会被忽略。
# 有关命令中支持的所有日期/时间输入格式,请参阅 docs/dates.md。
```
### Sheets
```
# 读取
gog sheets metadata
gog sheets get 'Sheet1!A1:B10'
# 导出(通过 Drive)
gog sheets export --format pdf --out ./sheet.pdf
gog sheets export --format xlsx --out ./sheet.xlsx
# 写入
gog sheets update 'A1' 'val1|val2,val3|val4'
gog sheets update 'A1' --values-json '[["a","b"],["c","d"]]'
gog sheets update 'Sheet1!A1:C1' 'new|row|data' --copy-validation-from 'Sheet1!A2:C2'
gog sheets append 'Sheet1!A:C' 'new|row|data'
gog sheets append 'Sheet1!A:C' 'new|row|data' --copy-validation-from 'Sheet1!A2:C2'
gog sheets clear 'Sheet1!A1:B10'
# 格式化
gog sheets format 'Sheet1!A1:B2' --format-json '{"textFormat":{"bold":true}}' --format-fields 'userEnteredFormat.textFormat.bold'
# 插入行/列
gog sheets insert "Sheet1" rows 2 --count 3
gog sheets insert "Sheet1" cols 3 --after
# 备注
gog sheets notes 'Sheet1!A1:B10'
# 创建
gog sheets create "My New Spreadsheet" --sheets "Sheet1,Sheet2"
```
### Forms
```
# Forms
gog forms get
gog forms create --title "Weekly Check-in" --description "Friday async update"
# 响应
gog forms responses list --max 20
gog forms responses get
```
### Apps Script
```
# 项目
gog appscript get
gog appscript content
gog appscript create --title "Automation Helpers"
gog appscript create --title "Bound Script" --parent-id
# 执行函数
gog appscript run myFunction --params '["arg1", 123, true]'
gog appscript run myFunction --dev-mode
```
### People
```
# 个人资料
gog people me
gog people get people/
# 搜索 Workspace 目录
gog people search "Ada Lovelace" --max 5
# 关系(默认为 people/me)
gog people relations
gog people relations people/ --type manager
```
### Chat
```
# Spaces
gog chat spaces list
gog chat spaces find "Engineering"
gog chat spaces create "Engineering" --member alice@company.com --member bob@company.com
# 消息
gog chat messages list spaces/ --max 5
gog chat messages list spaces/ --thread
gog chat messages list spaces/ --unread
gog chat messages send spaces/ --text "Build complete!" --thread spaces//threads/
# 会话
gog chat threads list spaces/
# 直接消息
gog chat dm space user@company.com
gog chat dm send user@company.com --text "ping"
```
注意:Chat 命令需要 Google Workspace 账户(不支持消费者 @gmail.com 账户)。
### 群组(Google Workspace)
```
# 列出您所属的群组
gog groups list
# 列出群组成员
gog groups members engineering@company.com
```
注意:Groups 命令需要 Cloud Identity API 和 `cloud-identity.groups.readonly` Scope。如果您收到权限错误,请重新认证:
```
gog auth add your@email.com --services groups --force-consent
```
### Classroom(Google Workspace for Education)
```
# 课程
gog classroom courses list
gog classroom courses list --role teacher
gog classroom courses get
gog classroom courses create --name "Math 101"
gog classroom courses update --name "Math 102"
gog classroom courses archive
gog classroom courses unarchive
gog classroom courses url
# 名单
gog classroom roster
gog classroom roster --students
gog classroom students add
gog classroom teachers add
# 作业
gog classroom coursework list
gog classroom coursework get
gog classroom coursework create --title "Homework 1" --type ASSIGNMENT --state PUBLISHED
gog classroom coursework update --title "Updated"
gog classroom coursework assignees --mode INDIVIDUAL_STUDENTS --add-student
# 资料
gog classroom materials list
gog classroom materials create --title "Syllabus" --state PUBLISHED
# 提交
gog classroom submissions list
gog classroom submissions get
gog classroom submissions grade --grade 85
gog classroom submissions return
gog classroom submissions turn-in
gog classroom submissions reclaim
# 公告
gog classroom announcements list
gog classroom announcements create --text "Welcome!"
gog classroom announcements update --text "Updated"
gog classroom announcements assignees --mode INDIVIDUAL_STUDENTS --add-student
# 主题
gog classroom topics list
gog classroom topics create --name "Unit 1"
gog classroom topics update --name "Unit 2"
# 邀请
gog classroom invitations list
gog classroom invitations create --role student
gog classroom invitations accept