Files
config-man/README.md
2026-03-20 20:19:33 +08:00

147 lines
3.1 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.
# Config-Man CLI 工具
Config-Man 是一个面向对象存储配置文件的 Python CLI支持查看配置、建议更新、强制更新以及配套的本地配置管理。项目已经整理为可直接通过 `uv tool` 运行和安装的命令行工具。
## 快速开始
### 从源码直接运行
在仓库根目录执行:
```bash
uv tool run --from . config-man --help
uv tool run --from . config-man show-config
uv tool run --from . config-man view --version 0.30 --mock
```
这种方式适合本地验证和临时使用。
### 安装为本地工具
如果需要长期使用,推荐安装:
```bash
uv tool install --from . config-man
config-man --help
config-man show-config
```
卸载和升级:
```bash
uv tool upgrade config-man
uv tool uninstall config-man
```
## 运行前置条件
- Python 3.9+
- `uv`
- `rclone`
- 可选的 Cloudflare 凭证与网络访问能力
`config-man` 的真实存储操作依赖系统中的 `rclone`。如果只是本地验证 CLI可优先使用 `--mock` 模式。
```bash
rclone version
```
## 常用命令
### 查看配置
```bash
config-man view --version 0.30 --mock
config-man view --version 0.30 --json --mock
```
### 建议更新
```bash
config-man suggest-update --platform android --target-version 0.29 --update-version 0.30 --mock
```
### 强制更新
```bash
config-man force-update --platform ios --target-version 0.29 --update-version 0.30 --mock
```
### 查看和写入本地配置
```bash
config-man show-config
config-man set-config --key storage.path --value ab
config-man set-config --key storage.rclone_remote --value remote
config-man setup-cloudflare --api-token <token> --zone-id <zone_id>
```
### 附加命令
项目还提供交互式加密命令:
```bash
uv tool run --from . config-man-encrypt
```
## 配置加载规则
配置优先级如下:
1. 命令行参数
2. 环境变量
3. 用户配置文件 `~/.config/config-man/config-man.json`
4. 项目默认配置
相关环境变量包括:
```bash
export CONFIG_MAN_STORAGE_PATH=ab
export CONFIG_MAN_STORAGE_RCLONE_REMOTE=remote
export CONFIG_MAN_CDN_BASE_URL=https://cdn.example.com
export CONFIG_MAN_CDN_CLOUDFLARE_API_TOKEN=your_api_token
export CONFIG_MAN_CDN_CLOUDFLARE_ZONE_ID=your_zone_id
```
## 存储结构
对象存储中的目标结构大致如下:
```text
ab/
├── 0_29/
│ ├── androidconfig.json
│ └── iosconfig.json
├── 0_30/
│ ├── androidconfig.json
│ └── iosconfig.json
└── 1_00/
├── androidconfig.json
└── iosconfig.json
```
版本号会自动从 `0.30` 转换为 `0_30` 这种路径形式。
## 构建与发布
如果你希望他人可以直接执行 `uv tool install config-man`,需要先构建并发布到包索引。
本地构建:
```bash
uv build
```
构建后的快速验证:
```bash
uv tool run --from dist/*.whl config-man --help
```
## 相关文档
- `docs/uv-tool.md`: 面向 `uv tool` 的安装、配置、验证与发布说明
- `docs/USAGE.md`: `view` 命令和配置方式说明
- `docs/cloudflare_setup.md`: Cloudflare 配置说明
- `PROJECT_STRUCTURE.md`: 项目结构与开发流程