一个轻量短小的 Python CLI 工具,用于在命令行管理 Google 日历事件——通过 Calendar API 列出、添加、更新、删除事件。
A single-file CLI for Google Calendar using only Python 3 standard library.
Create a Google Cloud project and enable the Google Calendar API.
Create OAuth 2.0 credentials (Desktop app). Note the client ID and secret.
Obtain a refresh token via the OAuth consent flow.
Export credentials: bash
export GOOGLE_CLIENT_ID=...
export GOOGLE_CLIENT_SECRET=...
export GOOGLE_REFRESH_TOKEN=...
export GOOGLE_CALENDAR_ID=primary # optional, defaults to "primary"
text
google-calendar-cli.py <command> [options]
CommandDescriptionlistList upcoming eventstodayShow today's eventsaddCreate a new eventupdateUpdate an existing eventdeleteDelete an event
Credentials can also be passed as flags ( --client-id, --client-secret, --refresh-token, --calendar-id).
Use --json for raw JSON output. Run with -h for full help.
bash
# List next 10 events
python3 {baseDir}/scripts/google-calendar-cli.py list
# Today's events
python3 {baseDir}/scripts/google-calendar-cli.py today
# Events in a date range
python3 {baseDir}/scripts/google-calendar-cli.py list --from 2025-06-01T00:00:00Z --to 2025-06-30T23:59:59Z
# Add an event
python3 {baseDir}/scripts/google-calendar-cli.py add --title "Meeting" \
--start 2025-06-01T09:00:00-07:00 --end 2025-06-01T10:00:00-07:00
# Update an event
python3 {baseDir}/scripts/google-calendar-cli.py update --event-id EVENT_ID --title "New Title"
# Delete an event
python3 {baseDir}/scripts/google-calendar-cli.py delete --event-id EVENT_ID