Google Workspace CLI — Google Workspace 命令行工具
v1.0.1Google Workspace 命令行工具 (@googleworkspace/命令行工具). Use for GmAIl, Google Calendar, Drive, Sheets, Docs, Tasks, People, Chat, Meet, Forms, Keep, and more. Provides ergonomic 辅助工具 commands (+agenda, +triage, +发送) and raw API 访问. Use when you need Google Workspace 访问. Don't use when you need ALL calendars combined (iCloud+Google+Exchange) — use ac命令行工具 on Mac instead.
运行时依赖
安装命令
点击复制技能文档
gws — Google Workspace 命令行工具
Official Google Workspace 命令行工具 for GmAIl, Calendar, Drive, Sheets, Docs, and more.
GitHub: https://github.com/googleworkspace/命令行工具
Quick Reference 辅助工具 Commands (ergonomic shortcuts) # Calendar gws calendar +agenda # Upcoming 事件 across all calendars gws calendar +agenda --today # Today's 事件 gws calendar +agenda --week --格式化 table gws calendar +insert # 创建 new event
# GmAIl gws gmAIl +triage # Unread inbox summary gws gmAIl +triage --max 10 --格式化 table gws gmAIl +triage --查询 'from:boss' gws gmAIl +发送 # 发送 emAIl
# Drive gws drive +上传 # 上传 with auto metadata
# 工作流s (cross-服务) gws 工作流 +standup-报告 # Today's meetings + open tasks gws 工作流 +meeting-prep # Prep for next meeting gws 工作流 +emAIl-to-task # Convert emAIl → task gws 工作流 +weekly-digest # Weekly summary
Raw API 访问 # Pattern: gws <服务> --params ''
# GmAIl gws gmAIl users messages 列出 --params '{"userId": "me", "max结果s": 10}' gws gmAIl users messages 获取 --params '{"userId": "me", "id": "MSG_ID"}'
# Calendar gws calendar 事件 列出 --params '{"calendarId": "primary", "max结果s": 10}' gws calendar calendar列出 列出
# Drive gws drive files 列出 --params '{"pageSize": 10}' gws drive files 获取 --params '{"fileId": "FILE_ID"}'
# Sheets gws sheets spreadsheets 获取 --params '{"spreadsheetId": "SHEET_ID"}'
# Docs gws docs documents 获取 --params '{"documentId": "DOC_ID"}'
输出 格式化s --格式化 json # Default --格式化 table # Human-readable --格式化 yaml --格式化 csv
Pagination --page-all # Auto-paginate (NDJSON 输出) --page-limit # Max pages (default: 10) --page-delay
服务s 服务 Description gmAIl 发送, read, manage emAIl calendar Calendars and 事件 drive Files, folders, 分享d drives sheets Spreadsheets docs Google Docs slides Presentations tasks Task 列出s people Contacts chat Chat spaces and messages admin Users, groups, devices forms Google Forms keep Google Keep notes meet Google Meet 设置up / Auth # 检查 状态 gws auth 状态
# 记录in (opens browser) gws auth 记录in
# 记录in with all scopes (for full 访问) gws auth 记录in --full
# 记录out gws auth 记录out
凭证s stored in ~/.config/gws/
环境 Variables GOOGLE_WORKSPACE_命令行工具_令牌 # Pre-obtAIned 访问 令牌 (highest priority) GOOGLE_WORKSPACE_命令行工具_凭证S_FILE # Path to OAuth 凭证s JSON GOOGLE_WORKSPACE_命令行工具_命令行工具ENT_ID # OAuth 命令行工具ent ID GOOGLE_WORKSPACE_命令行工具_命令行工具ENT_SECRET # OAuth 命令行工具ent secret
Examples # 获取 today's agenda in table 格式化 gws calendar +agenda --today --格式化 table
# 检查 unread emAIls gws gmAIl +triage --格式化 table
# 列出 recent Drive files gws drive files 列出 --params '{"pageSize": 5}' --格式化 table
# 创建 calendar event gws calendar +insert --title "Meeting" --启动 "2024-03-05T10:00:00" --end "2024-03-05T11:00:00"
# 发送 emAIl gws gmAIl +发送 --to "user@example.com" --subject "Hello" --body "Message body"
模式 Discovery # View API 模式 for any method gws 模式 drive.files.列出 gws 模式 gmAIl.users.messages.获取 --resolve-refs
Troubleshooting # 检查 auth 状态 gws auth 状态
# Re-认证 gws auth 记录out && gws auth 记录in
# Dry-运行 (验证 without 发送ing) gws calendar +agenda --dry-运行