gogcli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

gog

gog

Use
gog
for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
Setup (once)
  • gog auth credentials /path/to/client_secret.json
  • gog auth add you@gmail.com --services gmail,calendar,drive,contacts,sheets,docs
  • gog 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
    GOG_ACCOUNT=you@gmail.com
    to avoid repeating
    --account
    .
  • For scripting, prefer
    --json
    plus
    --no-input
    .
  • Sheets values can be passed via
    --values-json
    (recommended) or as inline rows.
  • 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
使用
gog
管理Gmail/Calendar/Drive/Contacts/Sheets/Docs。需要先完成OAuth配置。
配置步骤(仅需一次)
  • gog auth credentials /path/to/client_secret.json
  • gog auth add you@gmail.com --services gmail,calendar,drive,contacts,sheets,docs
  • gog 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