| name | gogcli-knowledge |
| description | Use when user asks about gogcli, gog CLI, Google CLI, Gmail CLI, Google Calendar CLI, Google Drive CLI, or Google Workspace CLI. Also use when user says gogcli について, Google CLI について, gog コマンド, Gmail 操作, カレンダー操作, ドライブ操作. Google Suite CLI (gogcli/gog) の仕様と使い方に関する知識を提供し、Gmail、Calendar、Drive、Contacts、Tasks、Sheets、Docs、Chat、Classroom、People、Groups、Keep の操作について回答する。 |
| context | fork |
gogcli Knowledge
Google Suite CLI (gogcli/gog) の仕様と使い方に関する包括的な知識を提供するスキル。
概要
gogcli は Google のサービス群(Gmail、Calendar、Drive、Contacts、Tasks、Sheets、Docs、Chat、Classroom 等)をターミナルから操作するための CLI ツール。JSON ファースト出力、マルチアカウント対応、最小権限認証を備える。
対応サービス
| サービス | コマンドグループ | 説明 |
|---|
| Gmail | gog gmail | スレッド・メッセージ検索、送信、ラベル、フィルタ、委任、Watch (Pub/Sub)、メール追跡 |
| Calendar | gog calendar | イベント CRUD、空き状況、チーム、招待、繰り返し、focus/OOO/working-location |
| Chat | gog chat | スペース、メッセージ、スレッド、DM(Workspace のみ) |
| Classroom | gog classroom | コース、名簿、課題、提出物、成績、お知らせ(Workspace for Education) |
| Drive | gog drive | ファイル一覧・検索・アップロード・ダウンロード、フォルダ、権限、共有ドライブ |
| Docs | gog docs | 情報取得、テキスト抽出、作成、コピー、エクスポート |
| Slides | gog slides | 情報取得、作成、コピー、エクスポート |
| Sheets | gog sheets | 読み書き、フォーマット、作成、エクスポート |
| Contacts | gog contacts | 個人連絡先、その他の連絡先、ディレクトリ(Workspace) |
| Tasks | gog tasks | タスクリスト管理、タスク CRUD、繰り返し |
| People | gog people | プロフィール、検索、リレーション |
| Groups | gog groups | グループ一覧、メンバー一覧(Workspace のみ) |
| Keep | gog keep | ノート一覧・取得・検索、添付ファイル(Workspace のみ、サービスアカウント必須) |
| Time | gog time | ローカル/UTC 時刻表示 |
インストール方法
Homebrew(推奨)
brew install steipete/tap/gogcli
ソースからビルド
git clone https://github.com/steipete/gogcli.git
cd gogcli
make
./bin/gog --help
ヘルプの確認
gog --help
gog <group> --help
GOG_HELP=full gog --help
認証設定
gogcli は OAuth2 で Google API にアクセスする。
OAuth2 クイックスタート
gog auth credentials ~/Downloads/client_secret_....json
gog auth add you@gmail.com
export GOG_ACCOUNT=you@gmail.com
gog gmail labels list
マルチアカウント
gog auth add personal@gmail.com
gog auth add work@company.com
gog auth list
gog auth list --check
gog gmail search 'is:unread' --account personal@gmail.com
gog gmail search 'is:unread' --account work@company.com
export GOG_ACCOUNT=work@company.com
gog auth alias set work work@company.com
gog gmail search 'is:unread' --account work
マルチ OAuth クライアント
gog --client work auth credentials ~/Downloads/work.json
gog --client work auth credentials ~/Downloads/work.json --domain example.com
gog auth credentials list
クライアント選択順序:
--client / GOG_CLIENT フラグ
account_clients 設定(email -> client)
client_domains 設定(domain -> client)
- メールドメインと同名の credentials ファイル
default
サービスアカウント(Workspace のみ)
ドメイン全体の委任(domain-wide delegation)によるユーザー偽装:
gog auth service-account set you@yourdomain.com --key ~/Downloads/service-account.json
gog --account you@yourdomain.com auth status
gog auth list
サービススコープ
gog auth add you@gmail.com --services drive,calendar
gog auth add you@gmail.com --services drive,calendar --readonly
gog auth add you@gmail.com --services drive --drive-scope full
gog auth add you@gmail.com --services drive --drive-scope readonly
gog auth add you@gmail.com --services drive --drive-scope file
gog auth add you@gmail.com --services sheets --force-consent
キーリングバックエンド
| バックエンド | 説明 |
|---|
auto | OS に最適なバックエンド(デフォルト) |
keychain | macOS Keychain(推奨) |
file | 暗号化ファイル(CI/SSH 向け) |
gog auth keyring file
gog auth keyring keychain
gog auth keyring auto
gog auth keyring
export GOG_KEYRING_BACKEND=file
export GOG_KEYRING_PASSWORD='...'
gog --no-input auth status
認証状態確認
gog auth status
gog auth services
gog auth list
gog auth list --check
gog auth remove <email>
コマンド体系
グローバルフラグ
| フラグ | 説明 |
|---|
--account <email|alias|auto> | 使用アカウント |
--client <name> | OAuth クライアント名 |
--json | JSON 出力 |
--plain | TSV 出力(パイプ向け) |
--color <auto|always|never> | カラーモード |
--force | 確認スキップ |
--no-input | 非インタラクティブモード |
--verbose | 詳細ログ |
--enable-commands <csv> | コマンド許可リスト |
Gmail
gog gmail search 'newer_than:7d' --max 10
gog gmail messages search 'newer_than:7d' --max 10 --include-body
gog gmail thread get <threadId>
gog gmail thread get <threadId> --download --out-dir ./attachments
gog gmail get <messageId>
gog gmail get <messageId> --format metadata
gog gmail url <threadId>
gog gmail thread modify <threadId> --add STARRED --remove INBOX
gog gmail send --to a@b.com --subject "Hi" --body "Hello"
gog gmail send --to a@b.com --subject "Hi" --body-file ./message.txt
gog gmail send --to a@b.com --subject "Hi" --body-html "<p>Hello</p>"
gog gmail drafts list
gog gmail drafts create --subject "Draft" --body "Body"
gog gmail drafts send <draftId>
gog gmail labels list
gog gmail labels get INBOX --json
gog gmail labels create "My Label"
gog gmail batch delete <messageId> <messageId>
gog gmail batch modify <messageId> <messageId> --add STARRED
gog gmail filters list
gog gmail filters create --from 'noreply@example.com' --add-label 'Notifications'
gog gmail autoforward get
gog gmail vacation get
gog gmail vacation enable --subject "Out of office" --message "..."
gog gmail sendas list
gog gmail delegates list
gog gmail watch start --topic projects/<p>/topics/<t> --label INBOX
gog gmail history --since <historyId>
メール追跡
gog gmail track setup --worker-url https://gog-email-tracker.<acct>.workers.dev
gog gmail send --to a@b.com --subject "Hi" --body-html "<p>Hello</p>" --track
gog gmail track opens <tracking_id>
gog gmail track opens --to recipient@example.com
gog gmail track status
Calendar
gog calendar calendars
gog calendar colors
gog calendar events <calendarId> --today
gog calendar events <calendarId> --tomorrow
gog calendar events <calendarId> --week
gog calendar events <calendarId> --days 3
gog calendar events <calendarId> --from today --to friday
gog calendar events --all
gog calendar event <calendarId> <eventId>
gog calendar search "meeting" --today
gog calendar create <calendarId> \
--summary "Meeting" \
--from 2025-01-15T10:00:00Z \
--to 2025-01-15T11:00:00Z \
--attendees "alice@example.com,bob@example.com" \
--location "Zoom"
gog calendar update <calendarId> <eventId> \
--summary "Updated" \
--send-updates all
gog calendar update <calendarId> <eventId> \
--add-attendee "alice@example.com"
gog calendar create <calendarId> \
--summary "Payment" \
--from 2025-02-11T09:00:00-03:00 \
--to 2025-02-11T09:15:00-03:00 \
--rrule "RRULE:FREQ=MONTHLY;BYMONTHDAY=11" \
--reminder "email:3d" \
--reminder "popup:30m"
gog calendar focus-time --from ... --to ...
gog calendar out-of-office --from ... --to ... --all-day
gog calendar working-location --type office --office-label "HQ" --from ... --to ...
gog calendar delete <calendarId> <eventId>
gog calendar respond <calendarId> <eventId> --status accepted
gog calendar respond <calendarId> <eventId> --status declined
gog calendar propose-time <calendarId> <eventId>
gog calendar freebusy --calendars "primary,work@example.com" \
--from 2025-01-15T00:00:00Z --to 2025-01-16T00:00:00Z
gog calendar conflicts --calendars "primary" --today
gog calendar team <group-email> --today
gog calendar team <group-email> --freebusy
Chat(Workspace のみ)
gog chat spaces list
gog chat spaces find "Engineering"
gog chat spaces create "Engineering" --member alice@company.com
gog chat messages list spaces/<spaceId> --max 5
gog chat messages list spaces/<spaceId> --unread
gog chat messages send spaces/<spaceId> --text "Hello"
gog chat threads list spaces/<spaceId>
gog chat dm space user@company.com
gog chat dm send user@company.com --text "ping"
Classroom(Workspace for Education)
gog classroom courses list
gog classroom courses get <courseId>
gog classroom courses create --name "Math 101"
gog classroom roster <courseId>
gog classroom students add <courseId> <userId>
gog classroom coursework list <courseId>
gog classroom coursework create <courseId> --title "Homework 1" --type ASSIGNMENT --state PUBLISHED
gog classroom submissions list <courseId> <courseworkId>
gog classroom submissions grade <courseId> <courseworkId> <submissionId> --grade 85
gog classroom announcements list <courseId>
gog classroom topics list <courseId>
Drive
gog drive ls --max 20
gog drive ls --parent <folderId>
gog drive search "invoice" --max 20
gog drive get <fileId>
gog drive url <fileId>
gog drive upload ./path/to/file --parent <folderId>
gog drive download <fileId> --out ./downloaded.bin
gog drive download <fileId> --format pdf --out ./exported.pdf
gog drive mkdir "New Folder" --parent <parentFolderId>
gog drive rename <fileId> "New Name"
gog drive move <fileId> --parent <destinationFolderId>
gog drive delete <fileId>
gog drive copy <fileId> "Copy Name"
gog drive permissions <fileId>
gog drive share <fileId> --to user --email user@example.com --role reader
gog drive unshare <fileId> --permission-id <permissionId>
gog drive drives --max 100
Docs / Slides
gog docs info <docId>
gog docs cat <docId> --max-bytes 10000
gog docs create "My Doc"
gog docs copy <docId> "My Doc Copy"
gog docs export <docId> --format pdf --out ./doc.pdf
gog slides info <presentationId>
gog slides create "My Deck"
gog slides copy <presentationId> "My Deck Copy"
gog slides export <presentationId> --format pptx --out ./deck.pptx
Sheets
gog sheets metadata <spreadsheetId>
gog sheets get <spreadsheetId> 'Sheet1!A1:B10'
gog sheets update <spreadsheetId> 'A1' 'val1|val2,val3|val4'
gog sheets update <spreadsheetId> 'A1' --values-json '[["a","b"],["c","d"]]'
gog sheets append <spreadsheetId> 'Sheet1!A:C' 'new|row|data'
gog sheets clear <spreadsheetId> 'Sheet1!A1:B10'
gog sheets format <spreadsheetId> 'Sheet1!A1:B2' \
--format-json '{"textFormat":{"bold":true}}' \
--format-fields 'userEnteredFormat.textFormat.bold'
gog sheets create "My Spreadsheet" --sheets "Sheet1,Sheet2"
gog sheets export <spreadsheetId> --format pdf --out ./sheet.pdf
gog sheets copy <spreadsheetId> "My Sheet Copy"
Contacts
gog contacts list --max 50
gog contacts search "Ada" --max 50
gog contacts get user@example.com
gog contacts create --given-name "John" --family-name "Doe" --email "john@example.com"
gog contacts update people/<resourceName> --given-name "Jane"
gog contacts delete people/<resourceName>
gog contacts other list --max 50
gog contacts other search "John"
gog contacts directory list --max 50
gog contacts directory search "Jane"
Tasks
gog tasks lists --max 50
gog tasks lists create <title>
gog tasks list <tasklistId> --max 50
gog tasks get <tasklistId> <taskId>
gog tasks add <tasklistId> --title "Task title"
gog tasks add <tasklistId> --title "Weekly" --due 2025-02-01 --repeat weekly --repeat-count 4
gog tasks update <tasklistId> <taskId> --title "New title"
gog tasks done <tasklistId> <taskId>
gog tasks undo <tasklistId> <taskId>
gog tasks delete <tasklistId> <taskId>
gog tasks clear <tasklistId>
People
gog people me
gog people get people/<userId>
gog people search "Ada Lovelace" --max 5
gog people relations
gog people relations people/<userId> --type manager
Groups(Workspace のみ)
gog groups list
gog groups members engineering@company.com
Keep(Workspace のみ)
gog keep list --account you@yourdomain.com
gog keep get <noteId> --account you@yourdomain.com
gog keep search <query> --account you@yourdomain.com
gog keep attachment <attachmentName> --out ./attachment.bin
Time
gog time now
gog time now --timezone UTC
Config
gog config path
gog config list
gog config keys
gog config get default_timezone
gog config set default_timezone UTC
gog config unset default_timezone
出力形式
| 形式 | フラグ | 用途 |
|---|
| テーブル | (デフォルト) | 人間向け表示 |
| TSV | --plain | パイプ処理向け(タブ区切り) |
| JSON | --json | スクリプティング・自動化向け |
gog --json drive ls --max 5 | jq '.files[] | select(.mimeType=="application/pdf")'
gog calendar get <calendarId> <eventId> --json
- データは stdout、エラー・進捗は stderr に出力
- カラーは TTY 接続時のみ自動有効(
--json, --plain では無効)
環境変数
| 変数 | 説明 |
|---|
GOG_ACCOUNT | デフォルトアカウント(email またはエイリアス) |
GOG_CLIENT | OAuth クライアント名 |
GOG_JSON | デフォルト JSON 出力 |
GOG_PLAIN | デフォルト plain 出力 |
GOG_COLOR | カラーモード: auto, always, never |
GOG_TIMEZONE | 出力タイムゾーン(IANA 名, UTC, local) |
GOG_ENABLE_COMMANDS | コマンド許可リスト(カンマ区切り) |
GOG_KEYRING_BACKEND | キーリングバックエンド: auto, keychain, file |
GOG_KEYRING_PASSWORD | キーリングパスワード(CI/非インタラクティブ向け) |
設定ファイル
形式: JSON5(コメント、末尾カンマ対応)
パス:
- macOS:
~/Library/Application Support/gogcli/config.json
- Linux:
~/.config/gogcli/config.json
- Windows:
%AppData%\\gogcli\\config.json
{
keyring_backend: "file",
default_timezone: "UTC",
account_aliases: {
work: "work@company.com",
personal: "me@gmail.com",
},
account_clients: {
"work@company.com": "work",
},
client_domains: {
"example.com": "work",
},
}
典型的なワークフロー
メール検索と添付ファイルダウンロード
gog gmail search 'newer_than:7d has:attachment' --max 10
gog gmail thread get <threadId> --download --out-dir ./attachments
カレンダーイベント作成
gog calendar freebusy --calendars "primary" \
--from 2025-01-15T00:00:00Z --to 2025-01-16T00:00:00Z
gog calendar create primary \
--summary "Team Standup" \
--from 2025-01-15T10:00:00Z --to 2025-01-15T10:30:00Z \
--attendees "alice@example.com,bob@example.com"
Drive ファイル検索とダウンロード
gog --json drive search "invoice filetype:pdf" --max 20 | \
jq -r '.files[] | .id' | \
while read fileId; do
gog drive download "$fileId"
done
Sheets へのデータ書き込み
cat data.csv | tr ',' '|' | gog sheets update <spreadsheetId> 'Sheet1!A1'
gog sheets update <spreadsheetId> 'A1' --values-json '[["a","b"],["c","d"]]'
マルチアカウント運用
gog auth alias set personal personal@gmail.com
gog auth alias set work work@company.com
gog gmail search 'is:unread' --account personal
gog gmail search 'is:unread' --account work
サンドボックス実行(エージェント向け)
export GOG_ENABLE_COMMANDS=calendar,tasks
gog calendar events primary --today
gog tasks list <tasklistId>
シェル補完
gog completion bash > $(brew --prefix)/etc/bash_completion.d/gog
gog completion zsh > "${fpath[1]}/_gog"
gog completion fish > ~/.config/fish/completions/gog.fish
gog completion powershell | Out-String | Invoke-Expression
セキュリティ
資格情報ストレージ
- macOS: Keychain Access
- Linux: Secret Service (GNOME Keyring, KWallet)
- Windows: Credential Manager
- フォールバック: 暗号化ファイル(
GOG_KEYRING_BACKEND=file)
ベストプラクティス
- OAuth クライアント資格情報をバージョン管理にコミットしない
- 開発と本番で異なる OAuth クライアントを使用
- 不要なアカウントは
gog auth remove で削除
- トークン漏洩の疑いがある場合は
--force-consent で再認証
FAQ
Q: どの Google アカウントが使えますか?
A: 個人の Google アカウント(@gmail.com)と Google Workspace アカウントの両方に対応。ただし Chat、Groups、Keep、Classroom は Workspace アカウントが必要。
Q: OAuth2 の設定手順は?
A: Google Cloud Console でプロジェクトを作成し、必要な API を有効化、OAuth2 クライアント(Desktop app タイプ)を作成してJSON をダウンロード。gog auth credentials <path> で保存後、gog auth add <email> で認証。
Q: CI/CD 環境で使えますか?
A: はい。GOG_KEYRING_BACKEND=file と GOG_KEYRING_PASSWORD を設定し、--no-input フラグで非インタラクティブ実行が可能。
Q: 複数の Google Cloud プロジェクトを使い分けられますか?
A: はい。--client フラグまたは GOG_CLIENT 環境変数で名前付き OAuth クライアントを選択可能。ドメインマッピングによる自動選択も対応。
Q: コマンドを制限できますか?
A: はい。--enable-commands フラグまたは GOG_ENABLE_COMMANDS 環境変数でトップレベルコマンドの許可リストを設定可能。エージェント・サンドボックス実行に最適。
Q: JSON 出力はどのコマンドで使えますか?
A: 全コマンドで --json フラグが使用可能。データは stdout、エラーは stderr に出力されるため、パイプ処理が安全に行える。