| name | gog |
| description | Google Workspace CLI for Gmail, Calendar, Drive, Contacts, Sheets, and Docs. 提供对Google Workspace服务的命令行访问。 |
| triggers | ["Google","谷歌","Gmail","Google Calendar","Google Drive","Google Sheets","Google Docs","谷歌日历","谷歌邮箱"] |
| homepage | https://gogcli.sh |
| metadata | {"clawdbot":{"emoji":"🎮","requires":{"bins":["gog"]},"install":[{"id":"brew","kind":"brew","formula":"steipete/tap/gogcli","bins":["gog"],"label":"Install gog (brew)"}]}} |
Google Workspace CLI (gog)
使用 gog 命令行工具管理 Gmail、日历、云盘、通讯录、表格和文档。需要 OAuth 2.0 授权设置。
🚀 快速开始
1. 首次设置
gog auth login
gog auth login --account your@gmail.com
export GOG_ACCOUNT=your@gmail.com
2. 验证登录状态
gog auth status
gog auth list
📧 Gmail 邮箱管理
邮箱操作
gog mail list --limit 10
gog mail list --query "subject:重要 from:boss"
gog mail cat <message-id>
gog mail send --to recipient@example.com --subject "测试邮件" --body "邮件内容"
gog mail send --to recipient@example.com --subject "带附件" --body "请看附件" --attach /path/to/file.pdf
邮件批量操作
gog mail mark-read <message-id>
gog mail move <message-id> --to INBOX/Important
gog mail delete <message-id>
📅 日历管理
事件操作
gog calendar events --limit 10
gog calendar create --summary "团队会议" --start "2024-03-15T10:00:00" --end "2024-03-15T11:00:00" --attendees "user1@example.com,user2@example.com"
gog calendar cat <event-id>
gog calendar update <event-id> --description "更新的会议说明"
gog calendar delete <event-id>
日历查询
gog calendar events --start "2024-03-01" --end "2024-03-31"
gog calendar events --calendar primary
gog calendar events --limit 5 --format json
📁 Google Drive 云盘
文件操作
gog drive list --limit 20
gog drive list --query "name contains '报告'"
gog drive cat <file-id>
gog drive download <file-id> --out /local/path/file.pdf
gog drive upload /local/file.pdf --name "上传的文件.pdf"
gog drive mkdir "新文件夹名称"
文件权限管理
gog drive share <file-id> --role reader --type user --email user@example.com
gog drive permissions <file-id>
📊 Google Sheets 表格
表格操作
gog sheets list
gog sheets create --title "新表格"
gog sheets cat <sheet-id>
gog sheets update <sheet-id> --range "A1:B10" --values-json '[["数据1","数据2"],["数据3","数据4"]]'
gog sheets metadata <sheet-id> --json
数据操作示例
gog sheets append <sheet-id> --range "Sheet1!A:A" --values-json '["新行数据1","新行数据2"]'
gog sheets values <sheet-id> --range "Sheet1!A1:C10" --json
📝 Google Docs 文档
文档操作
gog docs list
gog docs create --title "新文档"
gog docs cat <doc-id>
gog docs export <doc-id> --format txt --out /tmp/doc.txt
gog docs export <doc-id> --format pdf --out /tmp/doc.pdf
gog docs export <doc-id> --format html --out /tmp/doc.html
gog docs copy <doc-id> --title "文档副本"
📇 通讯录管理
联系人操作
gog contacts list
gog contacts list --query "张三"
gog contacts create --name "李四" --email "lisi@example.com" --phone "+861234567890"
gog contacts update <contact-id> --company "ABC公司"
⚙️ 配置与实用提示
环境变量
export GOG_ACCOUNT=your@gmail.com
export GOG_FORMAT=json
export GOG_NO_INPUT=1
实用技巧
- 批量处理:使用
--json 输出结合 jq 处理
- 自动化脚本:设置
--no-input 避免交互提示
- 数据格式化:使用
--values-json 传递结构化数据
- 身份验证缓存:登录后凭据会缓存,无需重复登录
常见用例
echo "邮件内容" | gog mail send --to list@example.com --subject "每日报告" --body -
gog calendar events --start "2024-01-01" --end "2024-12-31" --format json > calendar_events.json
find /local/path -name "*.pdf" | xargs -I {} gog drive upload {} --name "$(basename {})"
🚨 注意事项
- OAuth 授权:首次使用需要浏览器完成授权流程
- 敏感操作确认:发送邮件、创建事件等操作会请求确认
- API 限制:Google API 有调用频率限制
- 文件大小限制:Drive 上传有文件大小限制
- 文档编辑限制:gog 不支持文档内联编辑,仅支持导出/复制
📚 学习资源
gog --help
gog mail --help
gog calendar --help
gog version
官方文档:
相关技能:
himalaya: 其他邮箱的 IMAP/SMTP 管理
feishu: 飞书工作空间管理
personal-os: 个人操作系统集成