gws-gmail-watch
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegmail +watch
gmail +watch
PREREQUISITE: Readfor auth, global flags, and security rules. If missing, run../gws-shared/SKILL.mdto create it.gws generate-skills
Watch for new emails and stream them as NDJSON
前置要求: 阅读了解认证、全局标志和安全规则。如果该文件缺失,请运行../gws-shared/SKILL.md命令生成。gws generate-skills
监听新邮件并将其以NDJSON格式流式输出
Usage
使用方法
bash
gws gmail +watchbash
gws gmail +watchFlags
标志
| Flag | Required | Default | Description |
|---|---|---|---|
| — | — | GCP project ID for Pub/Sub resources |
| — | — | Existing Pub/Sub subscription name (skip setup) |
| — | — | Existing Pub/Sub topic with Gmail push permission already granted |
| — | — | Comma-separated Gmail label IDs to filter (e.g., INBOX,UNREAD) |
| — | 10 | Max messages per pull batch |
| — | 5 | Seconds between pulls |
| — | full | Gmail message format: full, metadata, minimal, raw |
| — | — | Pull once and exit |
| — | — | Delete created Pub/Sub resources on exit |
| — | — | Write each message to a separate JSON file in this directory |
| 标志 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| — | — | 用于Pub/Sub资源的GCP项目ID |
| — | — | 已存在的Pub/Sub订阅名称(跳过设置步骤) |
| — | — | 已授予Gmail推送权限的现有Pub/Sub主题 |
| — | — | 用于过滤的Gmail标签ID(逗号分隔,例如:INBOX,UNREAD) |
| — | 10 | 每次拉取的最大邮件数量 |
| — | 5 | 拉取间隔时间(秒) |
| — | full | Gmail邮件格式:full、metadata、minimal、raw |
| — | — | 仅拉取一次后退出 |
| — | — | 退出时删除已创建的Pub/Sub资源 |
| — | — | 将每封邮件写入该目录下的独立JSON文件 |
Examples
示例
bash
gws gmail +watch --project my-gcp-project
gws gmail +watch --project my-project --label-ids INBOX --once
gws gmail +watch --subscription projects/p/subscriptions/my-sub
gws gmail +watch --project my-project --cleanup --output-dir ./emailsbash
gws gmail +watch --project my-gcp-project
gws gmail +watch --project my-project --label-ids INBOX --once
gws gmail +watch --subscription projects/p/subscriptions/my-sub
gws gmail +watch --project my-project --cleanup --output-dir ./emailsTips
小贴士
- Gmail watch expires after 7 days — re-run to renew.
- Without --cleanup, Pub/Sub resources persist for reconnection.
- Press Ctrl-C to stop gracefully.
- Gmail监听会在7天后过期——需重新运行命令续期。
- 如果不使用--cleanup标志,Pub/Sub资源会保留以便重新连接。
- 按Ctrl-C可优雅停止程序。
See Also
另请参阅
- gws-shared — Global flags and auth
- gws-gmail — All send, read, and manage email commands
- gws-shared — 全局标志与认证
- gws-gmail — 所有发送、读取和管理邮件的命令