gws
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Workspace CLI (gws)
Google Workspace CLI(gws)
CLI for Gmail, Calendar, Drive, Sheets, Docs, Slides, Tasks, People, Chat, Meet, Forms, Keep, Admin, and cross-service workflows.
Binary:
/opt/homebrew/bin/gws用于Gmail、Calendar、Drive、Sheets、Docs、Slides、Tasks、People、Chat、Meet、Forms、Keep、Admin以及跨服务工作流的CLI工具。
二进制文件路径:
/opt/homebrew/bin/gwsCommand Pattern
命令格式
gws <service> <resource> [sub-resource] <method> [flags]Every command accepts:
- — URL/query parameters
--params <JSON> - — request body (POST/PATCH/PUT)
--json <JSON> - — file to upload as media content
--upload <PATH> - — path for binary responses (downloads)
--output <PATH> - — output format (default: json)
--format json|table|yaml|csv - /
--page-all— auto-paginate--page-limit N - — validate locally without sending
--dry-run
gws <service> <resource> [sub-resource] <method> [flags]所有命令支持以下参数:
- — URL/查询参数
--params <JSON> - — 请求体(POST/PATCH/PUT)
--json <JSON> - — 作为媒体内容上传的文件
--upload <PATH> - — 二进制响应(下载)的保存路径
--output <PATH> - — 输出格式(默认:json)
--format json|table|yaml|csv - /
--page-all— 自动分页--page-limit N - — 仅本地验证,不发送请求
--dry-run
Quick Reference — Helper Commands (prefer these)
快速参考——辅助命令(优先使用)
| Command | Purpose | R/W |
|---|---|---|
| Unread inbox summary | R |
| Send plaintext email | W |
| Stream new emails (Pub/Sub) | R |
| Upcoming events | R |
| Create event | W |
| Upload file | W |
| Read range (e.g. | R |
| Append row (or | W |
| Append text to doc | W |
| Post to Chat space | W |
| Today's meetings + open tasks | R |
| Next meeting details | R |
| Email → Task | W |
| Week's meetings + unread | R |
| Announce file in Chat | W |
| 命令 | 用途 | 读/写 |
|---|---|---|
| 未读收件箱摘要 | 读 |
| 发送纯文本邮件 | 写 |
| 流式接收新邮件(Pub/Sub) | 读 |
| 即将到来的事件 | 读 |
| 创建事件 | 写 |
| 上传文件 | 写 |
| 读取指定范围(例如 | 读 |
| 追加行(或使用 | 写 |
| 向文档追加文本 | 写 |
| 发送消息到Chat空间 | 写 |
| 今日会议+待办任务 | 读 |
| 下一场会议详情 | 读 |
| 邮件转任务 | 写 |
| 本周会议+未读邮件 | 读 |
| 在Chat中分享文件通知 | 写 |
Common Patterns
常用命令示例
Gmail
Gmail
bash
undefinedbash
undefinedTriage unread (table for humans)
分类处理未读邮件(表格格式便于阅读)
gws gmail +triage --max 10 --format table
gws gmail +triage --max 10 --format table
Search
搜索邮件
gws gmail users messages list --params '{"userId":"me","q":"from:amazon newer_than:7d","maxResults":5}'
gws gmail users messages list --params '{"userId":"me","q":"from:amazon newer_than:7d","maxResults":5}'
Read full message
读取完整邮件内容
gws gmail users messages get --params '{"userId":"me","id":"MSG_ID","format":"full"}'
gws gmail users messages get --params '{"userId":"me","id":"MSG_ID","format":"full"}'
Read headers only (faster)
仅读取邮件头(速度更快)
gws gmail users messages get --params '{"userId":"me","id":"MSG_ID","format":"metadata","metadataHeaders":["Subject","From","Date"]}'
gws gmail users messages get --params '{"userId":"me","id":"MSG_ID","format":"metadata","metadataHeaders":["Subject","From","Date"]}'
Archive (remove INBOX)
归档邮件(移除INBOX标签)
gws gmail users messages modify --params '{"userId":"me","id":"MSG_ID"}' --json '{"removeLabelIds":["INBOX"]}'
gws gmail users messages modify --params '{"userId":"me","id":"MSG_ID"}' --json '{"removeLabelIds":["INBOX"]}'
Trash
删除邮件到垃圾箱
gws gmail users messages trash --params '{"userId":"me","id":"MSG_ID"}'
gws gmail users messages trash --params '{"userId":"me","id":"MSG_ID"}'
Bulk label
批量添加标签
gws gmail users messages batchModify --params '{"userId":"me"}' --json '{"ids":["ID1","ID2"],"addLabelIds":["Label_123"]}'
undefinedgws gmail users messages batchModify --params '{"userId":"me"}' --json '{"ids":["ID1","ID2"],"addLabelIds":["Label_123"]}'
undefinedCalendar
Calendar
bash
undefinedbash
undefinedToday (Europe/Berlin default works with RFC3339 +02:00/+01:00)
查看今日日程(默认使用Europe/Berlin时区,兼容RFC3339格式的+02:00/+01:00偏移)
gws calendar +agenda --today --format table
gws calendar +agenda --today --format table
Create simple event
创建简单事件
gws calendar +insert
--summary 'AGENCY Meetup'
--start '2026-04-14T18:00:00+02:00'
--end '2026-04-14T19:00:00+02:00'
--location 'https://us02web.zoom.us/j/8991032224'
--description 'Zoom: https://us02web.zoom.us/j/8991032224'
--summary 'AGENCY Meetup'
--start '2026-04-14T18:00:00+02:00'
--end '2026-04-14T19:00:00+02:00'
--location 'https://us02web.zoom.us/j/8991032224'
--description 'Zoom: https://us02web.zoom.us/j/8991032224'
gws calendar +insert
--summary 'AGENCY Meetup'
--start '2026-04-14T18:00:00+02:00'
--end '2026-04-14T19:00:00+02:00'
--location 'https://us02web.zoom.us/j/8991032224'
--description 'Zoom: https://us02web.zoom.us/j/8991032224'
--summary 'AGENCY Meetup'
--start '2026-04-14T18:00:00+02:00'
--end '2026-04-14T19:00:00+02:00'
--location 'https://us02web.zoom.us/j/8991032224'
--description 'Zoom: https://us02web.zoom.us/j/8991032224'
Event WITH Google Meet link (helper doesn't support — use raw)
创建带Google Meet链接的事件(辅助命令不支持,需使用原生命令)
gws calendar events insert
--params '{"calendarId":"primary","conferenceDataVersion":1}'
--json '{ "summary":"Sync", "start":{"dateTime":"2026-04-15T14:00:00+02:00"}, "end":{"dateTime":"2026-04-15T15:00:00+02:00"}, "conferenceData":{"createRequest":{"requestId":"req-'$(date +%s)'","conferenceSolutionKey":{"type":"hangoutsMeet"}}} }'
--params '{"calendarId":"primary","conferenceDataVersion":1}'
--json '{ "summary":"Sync", "start":{"dateTime":"2026-04-15T14:00:00+02:00"}, "end":{"dateTime":"2026-04-15T15:00:00+02:00"}, "conferenceData":{"createRequest":{"requestId":"req-'$(date +%s)'","conferenceSolutionKey":{"type":"hangoutsMeet"}}} }'
gws calendar events insert
--params '{"calendarId":"primary","conferenceDataVersion":1}'
--json '{ "summary":"Sync", "start":{"dateTime":"2026-04-15T14:00:00+02:00"}, "end":{"dateTime":"2026-04-15T15:00:00+02:00"}, "conferenceData":{"createRequest":{"requestId":"req-'$(date +%s)'","conferenceSolutionKey":{"type":"hangoutsMeet"}}} }'
--params '{"calendarId":"primary","conferenceDataVersion":1}'
--json '{ "summary":"Sync", "start":{"dateTime":"2026-04-15T14:00:00+02:00"}, "end":{"dateTime":"2026-04-15T15:00:00+02:00"}, "conferenceData":{"createRequest":{"requestId":"req-'$(date +%s)'","conferenceSolutionKey":{"type":"hangoutsMeet"}}} }'
Update event
更新事件
gws calendar events patch --params '{"calendarId":"primary","eventId":"EID"}' --json '{"summary":"New title"}'
gws calendar events patch --params '{"calendarId":"primary","eventId":"EID"}' --json '{"summary":"New title"}'
Delete
删除事件
gws calendar events delete --params '{"calendarId":"primary","eventId":"EID"}'
gws calendar events delete --params '{"calendarId":"primary","eventId":"EID"}'
List all calendars
列出所有日历
gws calendar calendarList list --format table
undefinedgws calendar calendarList list --format table
undefinedDrive
Drive
bash
undefinedbash
undefinedUpload to root
上传文件到根目录
gws drive +upload ./report.pdf
gws drive +upload ./report.pdf
Upload to folder
上传文件到指定文件夹
gws drive +upload ./data.csv --parent FOLDER_ID --name 'Sales Data.csv'
gws drive +upload ./data.csv --parent FOLDER_ID --name 'Sales Data.csv'
Search files
搜索文件
gws drive files list --params '{"q":"name contains "report" and mimeType="application/pdf"","pageSize":10}'
gws drive files list --params '{"q":"name contains "report" and mimeType="application/pdf"","pageSize":10}'
Download
下载文件
gws drive files get --params '{"fileId":"FID","alt":"media"}' --output ./local.pdf
gws drive files get --params '{"fileId":"FID","alt":"media"}' --output ./local.pdf
Create folder
创建文件夹
gws drive files create --json '{"name":"MyFolder","mimeType":"application/vnd.google-apps.folder"}'
gws drive files create --json '{"name":"MyFolder","mimeType":"application/vnd.google-apps.folder"}'
Share with user
共享文件给指定用户
gws drive permissions create --params '{"fileId":"FID"}' --json '{"role":"reader","type":"user","emailAddress":"user@example.com"}'
undefinedgws drive permissions create --params '{"fileId":"FID"}' --json '{"role":"reader","type":"user","emailAddress":"user@example.com"}'
undefinedSheets
Sheets
bash
undefinedbash
undefinedRead
读取表格内容
gws sheets +read --spreadsheet SID --range 'Sheet1!A1:D10' --format table
gws sheets +read --spreadsheet SID --range 'Sheet1!A1:D10' --format table
Append single row (simple values)
追加单行数据(简单值格式)
gws sheets +append --spreadsheet SID --values 'Alice,100,true'
gws sheets +append --spreadsheet SID --values 'Alice,100,true'
Append multiple rows
追加多行数据
gws sheets +append --spreadsheet SID --json-values '[["a","b"],["c","d"]]'
undefinedgws sheets +append --spreadsheet SID --json-values '[["a","b"],["c","d"]]'
undefinedTasks
Tasks
bash
gws tasks tasklists list
gws tasks tasks list --params '{"tasklist":"@default"}'
gws tasks tasks insert --params '{"tasklist":"@default"}' --json '{"title":"My task","notes":"Details","due":"2026-04-20T00:00:00Z"}'
gws tasks tasks patch --params '{"tasklist":"@default","task":"TID"}' --json '{"status":"completed"}'bash
gws tasks tasklists list
gws tasks tasks list --params '{"tasklist":"@default"}'
gws tasks tasks insert --params '{"tasklist":"@default"}' --json '{"title":"My task","notes":"Details","due":"2026-04-20T00:00:00Z"}'
gws tasks tasks patch --params '{"tasklist":"@default","task":"TID"}' --json '{"status":"completed"}'Chat
Chat
bash
undefinedbash
undefinedFind space
查找Chat空间
gws chat spaces list --format table
gws chat spaces list --format table
Post message
发送消息
gws chat +send --space spaces/AAAAxxxx --text 'Hello team!'
undefinedgws chat +send --space spaces/AAAAxxxx --text 'Hello team!'
undefinedPeople / Contacts
People / 联系人
bash
gws people people connections list --params '{"resourceName":"people/me","personFields":"names,emailAddresses","pageSize":100}'
gws people people searchContacts --params '{"query":"John","readMask":"names,emailAddresses"}'bash
gws people people connections list --params '{"resourceName":"people/me","personFields":"names,emailAddresses","pageSize":100}'
gws people people searchContacts --params '{"query":"John","readMask":"names,emailAddresses"}'Critical Notes
重要注意事项
- userId: Every Gmail raw call needs in params.
"userId":"me" - RFC3339 times: Calendar uses full ISO with offset (). "Z" for UTC.
2026-04-14T18:00:00+02:00 - Meet links: does NOT add conferencing — use raw
+insertwithevents.insertandconferenceDataVersion=1.conferenceData.createRequest - Pagination: emits NDJSON (one JSON object per page).
--page-allcaps pages.--page-limit N - Schema discovery: — e.g.
gws schema <service>.<resource>.<method>.gws schema gmail.users.messages.list - Filters: scope required — special manual OAuth flow (see
gmail.settings.basic).references/api_reference.md - Write confirmation: Always confirm with user before ,
+send,+insert,+email-to-task,+file-announce,drive files delete,events delete.messages trash - Format choice: for human-readable summaries; default
--format tablefor scripting/piping tojson.jq
- userId:所有Gmail原生调用都需要在参数中包含。
"userId":"me" - RFC3339时间格式:Calendar使用带时区偏移的完整ISO格式(如),使用"Z"表示UTC时区。
2026-04-14T18:00:00+02:00 - Meet链接:命令不支持添加会议链接——需使用原生
+insert命令,并指定events.insert和conferenceDataVersion=1参数。conferenceData.createRequest - 分页:参数会输出NDJSON格式(每页一个JSON对象);
--page-all参数用于限制分页数量。--page-limit N - Schema发现:使用命令查看接口Schema——例如
gws schema <service>.<resource>.<method>。gws schema gmail.users.messages.list - 过滤器:需要权限范围——需手动执行OAuth流程(详见
gmail.settings.basic)。references/api_reference.md - 写入确认:执行、
+send、+insert、+email-to-task、+file-announce、drive files delete、events delete等写入操作前,需先获得用户确认。messages trash - 格式选择:用于生成便于人类阅读的摘要;默认的
--format table格式适用于脚本编写或通过json工具处理。jq
OAuth Setup
OAuth配置
- GCP project:
n8n-automations-454016 - Credentials:
~/.config/gws/credentials.json - Configured scopes: ,
gmail.modify,gmail.settings.basic,drive,spreadsheets,tasks,calendar,documents,chat.messagescontacts.readonly - scope needs manual OAuth (Python localhost listener on port 8085) —
gmail.settings.basiccannot request it directly.gws auth login --scopes
- GCP项目:
n8n-automations-454016 - 凭证文件路径:
~/.config/gws/credentials.json - 已配置权限范围:,
gmail.modify,gmail.settings.basic,drive,spreadsheets,tasks,calendar,documents,chat.messagescontacts.readonly - 权限范围需要手动OAuth流程(本地Python监听端口8085)——
gmail.settings.basic命令无法直接申请该权限。gws auth login --scopes
Full API Reference
完整API参考
For full command inventory, all raw API calls, pagination, labels, drafts, filters, and admin APIs, see .
references/api_reference.md如需查看完整命令清单、所有原生API调用、分页、标签、草稿、过滤器及管理员API,请参考。
references/api_reference.md