gogcli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegog
gog
Use for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
gogSetup (once)
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,sheets,docsgog auth list
Common commands
- Gmail search:
gog gmail search 'newer_than:7d' --max 10 - Gmail send:
gog gmail send --to a@b.com --subject "Hi" --body "Hello" - Calendar:
gog calendar events <calendarId> --from <iso> --to <iso> - Drive search:
gog drive search "query" --max 10 - Contacts:
gog contacts list --max 20 - Sheets get:
gog sheets get <sheetId> "Tab!A1:D10" --json - Sheets update:
gog sheets update <sheetId> "Tab!A1:B2" --values-json '[["A","B"],["1","2"]]' --input USER_ENTERED - Sheets append:
gog sheets append <sheetId> "Tab!A:C" --values-json '[["x","y","z"]]' --insert INSERT_ROWS - Sheets clear:
gog sheets clear <sheetId> "Tab!A2:Z" - Sheets metadata:
gog sheets metadata <sheetId> --json - Docs export:
gog docs export <docId> --format txt --out /tmp/doc.txt - Docs cat:
gog docs cat <docId>
Notes
- Set to avoid repeating
GOG_ACCOUNT=you@gmail.com.--account - For scripting, prefer plus
--json.--no-input - Sheets values can be passed via (recommended) or as inline rows.
--values-json - Docs supports export/cat/copy. In-place edits require a Docs API client (not in gog).
- Confirm before sending mail or creating events.
Gmail:
- Search Inbox:
gog gmail messages search "in:inbox" --max 200 --json - Archive:
gog gmail batch modify <id> --remove=INBOX --json --no-input
使用管理Gmail/Calendar/Drive/Contacts/Sheets/Docs。需要先完成OAuth配置。
gog配置步骤(仅需一次)
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,sheets,docsgog auth list
常用命令
- Gmail搜索:
gog gmail search 'newer_than:7d' --max 10 - Gmail发送邮件:
gog gmail send --to a@b.com --subject "Hi" --body "Hello" - 日历操作:
gog calendar events <calendarId> --from <iso> --to <iso> - Drive搜索:
gog drive search "query" --max 10 - 联系人列表:
gog contacts list --max 20 - Sheets获取数据:
gog sheets get <sheetId> "Tab!A1:D10" --json - Sheets更新数据:
gog sheets update <sheetId> "Tab!A1:B2" --values-json '[["A","B"],["1","2"]]' --input USER_ENTERED - Sheets追加数据:
gog sheets append <sheetId> "Tab!A:C" --values-json '[["x","y","z"]]' --insert INSERT_ROWS - Sheets清除数据:
gog sheets clear <sheetId> "Tab!A2:Z" - Sheets元数据:
gog sheets metadata <sheetId> --json - Docs导出:
gog docs export <docId> --format txt --out /tmp/doc.txt - Docs查看内容:
gog docs cat <docId>
注意事项
- 设置环境变量,避免重复使用
GOG_ACCOUNT=you@gmail.com参数。--account - 脚本编写时,建议使用参数搭配
--json参数。--no-input - Sheets的数据可通过参数传入(推荐方式),或直接以内联行形式传入。
--values-json - Docs支持导出/查看内容/复制操作。如需在线编辑,需要使用Docs API客户端(gog不支持该功能)。
- 发送邮件或创建日历事件前会进行确认。
Gmail进阶操作:
- 搜索收件箱:
gog gmail messages search "in:inbox" --max 200 --json - 归档邮件:
gog gmail batch modify <id> --remove=INBOX --json --no-input