名称: mog
描述: Microsoft Ops Gadget — 用于 Microsoft 365(邮件、日历、OneDrive、联系人、任务、Word、PowerPoint、Excel、OneNote)的命令行工具。
用于 Microsoft 365 的命令行工具:邮件、日历、OneDrive、联系人、任务、Word、PowerPoint、Excel、OneNote。
这是 gog(Google Ops Gadget)的 Microsoft 对应版本。模式相同,云服务不同。
要获取完整的使用说明,请运行:
mog --ai-help
这将输出符合 dashdash 规范的完整文档,包括:
- 设置/前提条件
- 所有命令和选项
- 日期/时间格式
- 示例(正面和反面)
- 故障排除
- Slug 系统说明
- gog 兼容性说明
| 模块 | 命令 |
|---|---|
| 邮件 | search, get, send, folders, drafts, attachment |
| 日历 | list, create, get, update, delete, calendars, respond, freebusy, acl |
| OneDrive | ls, search, download, upload, mkdir, move, rename, copy, rm |
| 联系人 | list, search, get, create, update, delete, directory |
| 任务 | lists, list, add, done, undo, delete, clear |
| Word | list, export, copy |
| PowerPoint | list, export, copy |
| Excel | list, get, update, append, create, metadata, tables, add-sheet, clear, copy, export |
| OneNote | notebooks, sections, pages, get, create-notebook, create-section, create-page, delete, search |
# 邮件
mog mail search "from:someone" --max 10
mog mail send --to a@b.com --subject "Hi" --body "Hello"
mog mail send --to a@b.com --subject "Report" --body-file report.md
mog mail send --to a@b.com --subject "Newsletter" --body-html "<h1>Hello</h1>"
cat draft.txt | mog mail send --to a@b.com --subject "Hi" --body-file -
# 日历
mog calendar list
mog calendar create --summary "Meeting" --from 2025-01-15T10:00:00 --to 2025-01-15T11:00:00
mog calendar freebusy alice@example.com bob@example.com
# OneDrive
mog drive ls
mog drive upload ./file.pdf
mog drive download <slug> --out ./file.pdf
# 任务
mog tasks list
mog tasks add "Buy milk" --due tomorrow
mog tasks clear
# 联系人
mog contacts list
mog contacts directory "john"
# Excel
mog excel list
mog excel get <id> Sheet1 A1:D10
mog excel update <id> Sheet1 A1:B2 val1 val2 val3 val4
mog excel append <id> TableName col1 col2 col3
# OneNote
mog onenote notebooks
mog onenote search "meeting notes"
mog 为 Microsoft 的长 GUID 生成 8 字符的 slug 标识符:
- 例如:a3f2c891 替代 AQMkADAwATMzAGZmAS04MDViLTRiNzgt...
- 所有命令都接受 slug 或完整 ID
- 使用 --verbose 查看完整 ID
mog cal → mog calendarmog todo → mog tasksOAuth 令牌存储在配置目录中(权限为 0600):
| 平台 | 位置 |
|---|---|
| macOS | ~/.config/mog/ |
| Linux | ~/.config/mog/ |
| Windows | %USERPROFILE%\.config\mog\ |
文件:
- tokens.json - OAuth 令牌(由操作系统静态加密)
- settings.json - 客户端 ID
- slugs.json - Slug 缓存
mog --ai-help - 完整文档mog <command> --help - 特定命令的帮助