gog 是做什麼的?
Google Workspace 命令列工具,支援 Gmail、日曆、雲端硬碟、聯絡人、試算表和文件。
功能
- Gmail:讀取、搜尋、傳送和管理電子郵件。
- 日曆:建立、更新和查詢日曆事件。
- 雲端硬碟:上傳、下載和管理檔案與資料夾。
- 聯絡人:管理聯絡人清單和群組。
- 試算表:讀取和編輯 Google 試算表資料。
- 文件:建立、讀取和更新 Google 文件。
安裝
npm install -g gog
或從 GitHub Releases 下載預編譯的二進位檔。
設定
- 從 Google Cloud Console 取得 OAuth 2.0 用戶端憑證。
- 設定環境變數:
export GOG_CLIENT_ID="your-client-id" export GOG_CLIENT_SECRET="your-client-secret" - 執行
gog auth以進行認證。
使用方式
Gmail
# 列出未讀郵件
gog gmail list --unread
# 傳送郵件
gog gmail send --to "[email protected]" --subject "Hello" --body "This is a test."
日曆
# 列出今日事件
gog calendar list --today
# 建立事件
gog calendar create --title "會議" --start "2024-01-01T10:00:00" --end "2024-01-01T11:00:00"
雲端硬碟
# 列出檔案
gog drive list --query "mimeType='application/vnd.google-apps.document'"
# 上傳檔案
gog drive upload --file /path/to/file.txt
聯絡人
# 列出聯絡人
gog contacts list
# 新增聯絡人
gog contacts create --name "John Doe" --email "[email protected]"
試算表
# 讀取試算表
gog sheets read --spreadsheet-id "abc123" --range "Sheet1!A1:B10"
# 更新儲存格
gog sheets update --spreadsheet-id "abc123" --range "Sheet1!A1" --value "新值"
文件
# 建立文件
gog docs create --title "我的文件" --content "這是內容。"
# 讀取文件
gog docs read --document-id "xyz456"
授權
MIT