Scripts2026年5月19日·1 分钟阅读

Google Workspace CLI — Command-Line Access to Drive, Gmail, Calendar and Sheets

An official open-source CLI from Google that lets developers and power users interact with Google Workspace services (Drive, Gmail, Calendar, Sheets, and more) directly from the terminal.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Stage only
信任
信任等级:Established
入口
Google Workspace CLI
安全暂存命令
npx -y tokrepo@latest install 4644e4a9-539f-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

Introduction

Google Workspace CLI (gws) is an official command-line tool that provides terminal access to Google Workspace services. It enables scripting, automation, and quick interactions with Drive, Gmail, Calendar, Sheets, and other Workspace products without opening a browser. The tool is designed for developers, sysadmins, and power users who prefer working from the command line.

What Google Workspace CLI Does

  • Manages Google Drive files: upload, download, list, search, and share
  • Sends, reads, and searches Gmail messages from the terminal
  • Creates, lists, and manages Google Calendar events
  • Reads, writes, and queries Google Sheets data programmatically
  • Supports scripting and piping for workflow automation

Architecture Overview

The CLI is a compiled binary that communicates with Google Workspace APIs using OAuth 2.0 authentication. It stores credentials locally after the initial browser-based login flow. Each subcommand maps to a specific Workspace API endpoint, handling pagination, retries, and rate limiting transparently. Output formats include JSON, table, and CSV for easy integration with other command-line tools.

Self-Hosting & Configuration

  • Install the binary via Homebrew, apt, or direct download from GitHub releases
  • Run gws auth login to complete OAuth authentication in a browser
  • Set GWS_DEFAULT_ACCOUNT to switch between multiple Google accounts
  • Configure output format globally with gws config set output json
  • Use --project flag to scope operations to a specific Google Cloud project

Key Features

  • Unified CLI for Drive, Gmail, Calendar, Sheets, and other Workspace services
  • JSON, table, and CSV output formats for scripting and data pipelines
  • Batch operations for uploading or downloading multiple files at once
  • Tab completion for Bash, Zsh, Fish, and PowerShell
  • Cross-platform support for macOS, Linux, and Windows

Comparison with Similar Tools

  • gdrive — community CLI for Google Drive only; gws covers the full Workspace suite
  • rclone — multi-cloud file sync; gws provides deeper Workspace-specific features like Gmail and Calendar
  • Google Cloud CLI (gcloud) — targets Google Cloud Platform infrastructure; gws targets Workspace productivity apps
  • GAM — admin-focused Google Workspace CLI; gws targets end-user productivity workflows
  • mutt/neomutt — terminal mail clients; gws provides native Gmail API integration with labels and threads

FAQ

Q: Does it work with personal Gmail accounts? A: Yes. It supports both personal Google accounts and Google Workspace organizational accounts.

Q: Can I use it in CI/CD pipelines? A: Yes. Service account authentication is supported for headless environments.

Q: Is my data stored locally? A: Only OAuth tokens are stored locally. All data operations go directly through Google's APIs.

Q: Can I pipe output to other commands? A: Yes. Use --output json to produce structured output suitable for jq, awk, or other CLI tools.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产