gws-gmail-watch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

gmail +watch

gmail +watch

PREREQUISITE: Read
../gws-shared/SKILL.md
for auth, global flags, and security rules. If missing, run
gws generate-skills
to create it.
Watch for new emails and stream them as NDJSON
前置要求: 阅读
../gws-shared/SKILL.md
了解认证、全局标志和安全规则。如果该文件缺失,请运行
gws generate-skills
命令生成。
监听新邮件并将其以NDJSON格式流式输出

Usage

使用方法

bash
gws gmail +watch
bash
gws gmail +watch

Flags

标志

FlagRequiredDefaultDescription
--project
——GCP project ID for Pub/Sub resources
--subscription
——Existing Pub/Sub subscription name (skip setup)
--topic
——Existing Pub/Sub topic with Gmail push permission already granted
--label-ids
——Comma-separated Gmail label IDs to filter (e.g., INBOX,UNREAD)
--max-messages
—10Max messages per pull batch
--poll-interval
—5Seconds between pulls
--msg-format
—fullGmail message format: full, metadata, minimal, raw
--once
——Pull once and exit
--cleanup
——Delete created Pub/Sub resources on exit
--output-dir
——Write each message to a separate JSON file in this directory
标志是否必填默认值描述
--project
——用于Pub/Sub资源的GCP项目ID
--subscription
——已存在的Pub/Sub订阅名称(跳过设置步骤)
--topic
——已授予Gmail推送权限的现有Pub/Sub主题
--label-ids
——用于过滤的Gmail标签ID(逗号分隔,例如:INBOX,UNREAD)
--max-messages
—10每次拉取的最大邮件数量
--poll-interval
—5拉取间隔时间(秒)
--msg-format
—fullGmail邮件格式:full、metadata、minimal、raw
--once
——仅拉取一次后退出
--cleanup
——退出时删除已创建的Pub/Sub资源
--output-dir
——将每封邮件写入该目录下的独立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 ./emails
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 ./emails

Tips

小贴士

  • 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 — 所有发送、读取和管理邮件的命令