Files
cli-anything-codimd/README.md
Timmy 8575d7631f Add admin reset-password command
Features:
- Add admin reset-password command to reset user passwords
- Support SQLite, PostgreSQL, and MySQL databases
- Use scrypt hashing compatible with CodiMD
- Update README with reset-password usage examples
2026-04-07 12:27:23 +08:00

134 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CodiMD CLI
CodiMD 的命令列工具 - 讓你可以透過終端機管理 CodiMD 協作筆記。
## 安裝
```bash
# 從 Git 仓库安裝(含管理員功能)
pip install -e ".[admin]" git+http://192.168.42.124:31337/timmy/cli-anything-codimd.git
# 或是複製後手動安裝
git clone http://192.168.42.124:31337/timmy/cli-anything-codimd.git
cd cli-anything-codimd/agent-harness
pip install -e ".[admin]"
```
## 使用方法
```bash
# 設定你的 CodiMD 伺服器
cli-anything-codimd config set server https://your-codimd-server.com
# 登入
cli-anything-codimd user login
# 查看登入狀態
cli-anything-codimd user status
# 列出所有筆記
cli-anything-codimd note list
# 取得筆記內容
cli-anything-codimd note get <note-id>
# 匯出筆記
cli-anything-codimd export markdown <note-id> -o note.md
# 建立 REPL 模式
cli-anything-codimd repl
```
## 指令
### 使用者指令
| 指令 | 說明 |
|------|------|
| `user login` | 登入帳號 |
| `user logout` | 登出 |
| `user status` | 查看登入狀態 |
| `user me` | 取得使用者資訊 |
### 筆記指令
| 指令 | 說明 |
|------|------|
| `note list` | 列出所有筆記 |
| `note get <id>` | 取得筆記內容 |
| `note create` | 建立新筆記 |
| `note update <id>` | 更新筆記內容 |
| `note delete <id>` | 刪除筆記 |
| `note info <id>` | 取得筆記資訊 |
| `note publish <id>` | 取得發布連結 |
### 匯出指令
| 指令 | 說明 |
|------|------|
| `export markdown <id>` | 匯出為 Markdown |
| `export pdf <id>` | 匯出為 PDF |
| `export html <id>` | 匯出為 HTML |
| `export slide <id>` | 匯出為投影片 |
### 修訂指令
| 指令 | 說明 |
|------|------|
| `revision list <id>` | 查看修訂歷史 |
| `revision get <id> <time>` | 取得特定時間的版本 |
### 管理員指令
需要直接存取 CodiMD 資料庫,需要安裝額外依賴:`pip install -e ".[admin]"`
| 指令 | 說明 |
|------|------|
| `admin list-users` | 列出所有使用者 |
| `admin user-notes <id>` | 列出使用者的筆記 |
| `admin reset-password` | 重設使用者密碼 |
#### 資料庫使用範例
```bash
# 列出所有使用者SQLite
cli-anything-codimd admin list-users --db-path ./db.sqlite
# 列出所有使用者PostgreSQL
cli-anything-codimd admin list-users --db-type postgresql \
--db-host localhost --db-name codimd --db-user postgres
# 列出所有使用者MySQL
cli-anything-codimd admin list-users --db-type mysql \
--db-host localhost --db-name codimd --db-user root
# 查看特定使用者的筆記
cli-anything-codimd admin user-notes <user-id> --db-path ./db.sqlite
# 重設使用者密碼(透過 Email
cli-anything-codimd admin reset-password --email user@example.com \
--db-path ./db.sqlite
# 重設使用者密碼(透過 User ID
cli-anything-codimd admin reset-password --user-id <user-id> \
--db-path ./db.sqlite
# 重設密碼PostgreSQL
cli-anything-codimd admin reset-password --email user@example.com \
--db-type postgresql --db-host localhost --db-name codimd --db-user postgres
```
### 設定指令
| 指令 | 說明 |
|------|------|
| `config get [key]` | 取得設定值 |
| `config set <key> <value>` | 設定值 |
## JSON 模式
所有指令都支援 `--json` 參數輸出機器可讀格式:
```bash
cli-anything-codimd --json note list
cli-anything-codimd --json admin list-users --db-path ./db.sqlite
```
## 授權
MIT License