fileflow-cli 0.1.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. fileflow_cli-0.2.1/PKG-INFO +319 -0
  2. fileflow_cli-0.2.1/README.md +281 -0
  3. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/pyproject.toml +7 -3
  4. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/__init__.py +1 -1
  5. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/actions.py +1 -1
  6. fileflow_cli-0.2.1/src/fileflow/cli.py +368 -0
  7. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/config.py +5 -14
  8. fileflow_cli-0.2.1/src/fileflow/engine.py +283 -0
  9. fileflow_cli-0.2.1/src/fileflow/history.py +170 -0
  10. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/matchers.py +5 -8
  11. fileflow_cli-0.2.1/src/fileflow/report.py +181 -0
  12. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/rules.py +1 -2
  13. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/templates.py +10 -4
  14. fileflow_cli-0.2.1/src/fileflow_cli.egg-info/PKG-INFO +319 -0
  15. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow_cli.egg-info/SOURCES.txt +2 -0
  16. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_actions.py +6 -2
  17. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_engine.py +12 -9
  18. fileflow_cli-0.2.1/tests/test_history.py +132 -0
  19. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_matchers.py +1 -2
  20. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_templates.py +1 -2
  21. fileflow_cli-0.1.0/PKG-INFO +0 -204
  22. fileflow_cli-0.1.0/README.md +0 -165
  23. fileflow_cli-0.1.0/src/fileflow/cli.py +0 -193
  24. fileflow_cli-0.1.0/src/fileflow/engine.py +0 -167
  25. fileflow_cli-0.1.0/src/fileflow/report.py +0 -164
  26. fileflow_cli-0.1.0/src/fileflow_cli.egg-info/PKG-INFO +0 -204
  27. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/LICENSE +0 -0
  28. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/setup.cfg +0 -0
  29. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow/__main__.py +0 -0
  30. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow_cli.egg-info/dependency_links.txt +0 -0
  31. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow_cli.egg-info/entry_points.txt +0 -0
  32. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow_cli.egg-info/requires.txt +0 -0
  33. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/src/fileflow_cli.egg-info/top_level.txt +0 -0
  34. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_config.py +0 -0
  35. {fileflow_cli-0.1.0 → fileflow_cli-0.2.1}/tests/test_rules.py +0 -0
@@ -0,0 +1,319 @@
1
+ Metadata-Version: 2.4
2
+ Name: fileflow-cli
3
+ Version: 0.2.1
4
+ Summary: 🧹 智能文件整理器 — YAML 规则引擎驱动的 CLI 文件分类/移动/清理工具
5
+ Author-email: Yuluo <lingeryuluo@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Linger668/fileflow
8
+ Project-URL: Repository, https://github.com/Linger668/fileflow
9
+ Project-URL: Issues, https://github.com/Linger668/fileflow/issues
10
+ Keywords: file-organization,file-management,cli,productivity
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Desktop Environment :: File Managers
21
+ Classifier: Topic :: Utilities
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: typer>=0.12.0
26
+ Requires-Dist: rich>=13.7.0
27
+ Requires-Dist: pyyaml>=6.0
28
+ Provides-Extra: watch
29
+ Requires-Dist: watchdog>=4.0.0; extra == "watch"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.5.0; extra == "dev"
34
+ Requires-Dist: mypy>=1.10.0; extra == "dev"
35
+ Requires-Dist: build>=1.0.0; extra == "dev"
36
+ Requires-Dist: twine>=5.0.0; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <div align="center">
40
+
41
+ # 🧹 FileFlow CLI
42
+
43
+ **智能文件整理器 — YAML 规则引擎驱动的 CLI 文件分类/移动/清理工具**
44
+
45
+ [![PyPI version](https://img.shields.io/pypi/v/fileflow-cli?style=flat-square&logo=pypi&logoColor=white&color=blue)](https://pypi.org/project/fileflow-cli/)
46
+ [![Python Version](https://img.shields.io/pypi/pyversions/fileflow-cli?style=flat-square&logo=python&logoColor=white)](https://pypi.org/project/fileflow-cli/)
47
+ [![Downloads](https://img.shields.io/pypi/dm/fileflow-cli?style=flat-square&color=brightgreen)](https://pypi.org/project/fileflow-cli/)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
49
+ [![Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=flat-square)](https://github.com/astral-sh/ruff)
50
+ [![GitHub Stars](https://img.shields.io/github/stars/Linger668/fileflow?style=flat-square&logo=github)](https://github.com/Linger668/fileflow)
51
+
52
+ ---
53
+
54
+ <p align="center">
55
+ <b>🇬🇧 English</b> · <a href="README_zh.md">🇨🇳 简体中文</a>
56
+ </p>
57
+
58
+ ---
59
+
60
+ </div>
61
+
62
+ ## ✨ 一分钟上手
63
+
64
+ ```bash
65
+ # 1. 安装
66
+ pip install fileflow-cli
67
+
68
+ # 2. 进入乱糟糟的下载目录
69
+ cd ~/Downloads
70
+
71
+ # 3. 生成配置文件
72
+ fileflow init
73
+
74
+ # 4. 预览整理效果(安全,不会动你的文件)
75
+ fileflow run .
76
+
77
+ # 5. 确认后执行整理
78
+ fileflow run . --force
79
+ ```
80
+
81
+ **搞定!** 你的文件被自动分类到 `Pictures/`、`Documents/`、`Code/`、`Videos/`、`Audio/` 等目录。
82
+
83
+ ---
84
+
85
+ ## 🎯 解决什么问题?
86
+
87
+ > **你的 Downloads 文件夹是不是像这样?**
88
+
89
+ ```
90
+ 📁 Downloads/
91
+ ├── IMG_2024.jpg
92
+ ├── project_report.pdf
93
+ ├── meeting_notes.docx
94
+ ├── screenshot.png
95
+ ├── vacation_photo.jpg
96
+ ├── budget_2024.xlsx
97
+ ├── app.py
98
+ ├── style.css
99
+ ├── video.mp4
100
+ ├── song.mp3
101
+ ├── archive.zip
102
+ ├── another_doc.pdf
103
+ ├── script.js
104
+ ├── logo.svg
105
+ ├── photo_from_2019.jpg
106
+ ...
107
+ ```
108
+
109
+ **整理后 →**
110
+
111
+ ```
112
+ 📁 Downloads/
113
+ ├── 📁 Pictures/jpg/vacation_photo.jpg
114
+ │ png/screenshot.png
115
+ │ svg/logo.svg
116
+ ├── 📁 Documents/pdf/project_report.pdf
117
+ │ docx/meeting_notes.docx
118
+ │ xlsx/budget_2024.xlsx
119
+ ├── 📁 Code/py/app.py
120
+ │ css/style.css
121
+ │ js/script.js
122
+ ├── 📁 Videos/mp4/video.mp4
123
+ ├── 📁 Audio/mp3/song.mp3
124
+ ├── 📁 Archives/zip/archive.zip
125
+ ```
126
+
127
+ **干净、有序、一目了然。**
128
+
129
+ ---
130
+
131
+ ## 🚀 功能特性
132
+
133
+ | 特性 | 说明 |
134
+ |------|------|
135
+ | 🎯 **YAML 规则引擎** | 声明式配置,想怎么分就怎么分 |
136
+ | 🔍 **预览模式** | 先看效果再执行,安全无副作用 |
137
+ | 📂 **6 种匹配方式** | 扩展名/通配符/正则/文件名包含/文件大小/组合 AND |
138
+ | 📦 **文件操作** | 移动/复制/删除,自动创建目录 |
139
+ | ⚡ **冲突处理** | 跳过/重命名/覆盖,策略可选 |
140
+ | ⏪ **支持撤销** | `fileflow undo` 一键回退 |
141
+ | 📊 **统计功能** | `fileflow stats` 查看整理记录 |
142
+ | 🔌 **可扩展** | 匹配器和操作都支持插件式注册 |
143
+ | 🎨 **终端美化** | Rich 进度条 + 彩色表格 |
144
+ | 🪶 **轻量依赖** | 只需 typer + rich + pyyaml |
145
+
146
+ ---
147
+
148
+ ## 📖 详细用法
149
+
150
+ ### 命令一览
151
+
152
+ ```bash
153
+ fileflow init # 🚀 生成默认 .fileflow.yaml
154
+ fileflow run . # 🔍 预览整理效果
155
+ fileflow run . --force # 📦 执行整理
156
+ fileflow validate # ✅ 验证配置文件
157
+ fileflow list-rules # 📋 查看规则列表
158
+ fileflow stats # 📊 查看统计信息
159
+ fileflow undo # ⏪ 撤销最近操作
160
+ fileflow --help # 📖 查看帮助
161
+ ```
162
+
163
+ ### 常用选项
164
+
165
+ | 选项 | 说明 |
166
+ |------|------|
167
+ | `--config, -c` | 指定配置文件 |
168
+ | `--dry-run, -n` | 仅预览模式 |
169
+ | `--force, -f` | 跳过预览,直接执行 |
170
+ | `--yes, -y` | 跳过所有确认提示 |
171
+ | `--no-recursive` | 不扫描子目录 |
172
+ | `--no-progress` | 不显示进度条 |
173
+ | `--verbose, -v` | 详细输出 |
174
+ | `--version, -V` | 显示版本 |
175
+
176
+ ### 示例
177
+
178
+ ```bash
179
+ # 整理桌面
180
+ fileflow run ~/Desktop
181
+
182
+ # 使用自定义配置
183
+ fileflow run . --config ~/my-rules.yaml
184
+
185
+ # 不递归子目录
186
+ fileflow run . --force --no-recursive
187
+
188
+ # 只预览,不确认
189
+ fileflow run . --dry-run -y
190
+
191
+ # 撤销最近 3 次操作
192
+ fileflow undo --steps 3
193
+
194
+ # 撤销所有操作
195
+ fileflow undo --all
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 📝 配置文件 (.fileflow.yaml)
201
+
202
+ ```yaml
203
+ version: "1.0"
204
+
205
+ settings:
206
+ dry_run_by_default: true # 默认预览模式
207
+ on_conflict: "skip" # skip | rename | overwrite
208
+ create_target_dirs: true
209
+
210
+ rules:
211
+ - name: "整理图片"
212
+ description: "按扩展名分类图片"
213
+ match:
214
+ extensions: [".jpg", ".jpeg", ".png", ".gif", ".svg", ".bmp"]
215
+ action: move
216
+ target: "Pictures/{ext_no_dot}/{filename}"
217
+
218
+ - name: "整理文档"
219
+ match:
220
+ extensions: [".pdf", ".doc", ".docx", ".xls", ".xlsx"]
221
+ max_size_mb: 50 # 忽略超过 50MB 的文件
222
+ action: move
223
+ target: "Documents/{ext_no_dot}/{filename}"
224
+
225
+ - name: "清理旧日志"
226
+ match:
227
+ extensions: [".log"]
228
+ min_size_mb: 100 # 只处理超过 100MB 的日志
229
+ action: delete
230
+ enabled: false # 默认禁用,需手动启用
231
+ ```
232
+
233
+ ### 📂 路径模板变量
234
+
235
+ | 变量 | 说明 | 示例值 |
236
+ |------|------|--------|
237
+ | `{filename}` | 完整文件名 | `report.pdf` |
238
+ | `{name}` | 文件名(无扩展名) | `report` |
239
+ | `{ext_no_dot}` | 扩展名(无点,推荐目录用) | `pdf` |
240
+ | `{ext}` | 扩展名(含点) | `.pdf` |
241
+ | `{year}` | 4 位年份 | `2026` |
242
+ | `{month}` | 2 位月份 | `07` |
243
+ | `{day}` | 2 位日期 | `13` |
244
+
245
+ > **推荐使用 `{ext_no_dot}` 作为目录名**,如 `Documents/pdf/report.pdf`,而不是 `Documents/.pdf/report.pdf`。
246
+
247
+ ---
248
+
249
+ ## 🏗 项目架构
250
+
251
+ ```
252
+ fileflow/
253
+ ├── src/fileflow/
254
+ │ ├── cli.py # CLI 命令 (Typer)
255
+ │ ├── config.py # YAML 配置加载 & 验证
256
+ │ ├── engine.py # 核心引擎 (扫描→匹配→执行)
257
+ │ ├── history.py # 操作历史 & Undo
258
+ │ ├── rules.py # 规则数据模型
259
+ │ ├── matchers.py # 匹配器注册表 + 6 种内置匹配器
260
+ │ ├── actions.py # 文件操作注册表 (move/copy/delete)
261
+ │ ├── templates.py # 路径模板变量解析
262
+ │ └── report.py # Rich 终端美化输出
263
+ ├── tests/ # 76 项单元测试
264
+ ├── .github/ # CI/CD 自动化
265
+ └── pyproject.toml # 项目配置
266
+ ```
267
+
268
+ ### 🧩 设计亮点
269
+
270
+ **匹配器注册表模式** — 新增匹配器只需注册,无需修改其他代码:
271
+
272
+ ```python
273
+ @register("my_matcher")
274
+ class MyMatcher(Matcher):
275
+ def __call__(self, path: Path) -> bool:
276
+ return path.suffix == ".xyz"
277
+ ```
278
+
279
+ ---
280
+
281
+ ## 🧪 开发 & 测试
282
+
283
+ ```bash
284
+ git clone https://github.com/Linger668/fileflow.git
285
+ cd fileflow
286
+ pip install -e ".[dev]"
287
+
288
+ # 运行测试
289
+ pytest
290
+
291
+ # 代码检查
292
+ ruff check src/
293
+ ruff format src/
294
+ mypy src/
295
+ ```
296
+
297
+ ---
298
+
299
+ ## 🤝 贡献
300
+
301
+ 欢迎提交 [Issue](https://github.com/Linger668/fileflow/issues) 和 [PR](https://github.com/Linger668/fileflow/pulls)!
302
+
303
+ **新手友好** 👉 查看 [good first issues](https://github.com/Linger668/fileflow/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
304
+
305
+ ---
306
+
307
+ ## 📄 许可证
308
+
309
+ [MIT](LICENSE) © 2026 Yuluo
310
+
311
+ ---
312
+
313
+ <div align="center">
314
+
315
+ **如果 FileFlow 帮到了你,请给它 ⭐ 支持一下!** 🌟
316
+
317
+ [![GitHub Stars](https://img.shields.io/github/stars/Linger668/fileflow?style=social)](https://github.com/Linger668/fileflow)
318
+
319
+ </div>
@@ -0,0 +1,281 @@
1
+ <div align="center">
2
+
3
+ # 🧹 FileFlow CLI
4
+
5
+ **智能文件整理器 — YAML 规则引擎驱动的 CLI 文件分类/移动/清理工具**
6
+
7
+ [![PyPI version](https://img.shields.io/pypi/v/fileflow-cli?style=flat-square&logo=pypi&logoColor=white&color=blue)](https://pypi.org/project/fileflow-cli/)
8
+ [![Python Version](https://img.shields.io/pypi/pyversions/fileflow-cli?style=flat-square&logo=python&logoColor=white)](https://pypi.org/project/fileflow-cli/)
9
+ [![Downloads](https://img.shields.io/pypi/dm/fileflow-cli?style=flat-square&color=brightgreen)](https://pypi.org/project/fileflow-cli/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
11
+ [![Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg?style=flat-square)](https://github.com/astral-sh/ruff)
12
+ [![GitHub Stars](https://img.shields.io/github/stars/Linger668/fileflow?style=flat-square&logo=github)](https://github.com/Linger668/fileflow)
13
+
14
+ ---
15
+
16
+ <p align="center">
17
+ <b>🇬🇧 English</b> · <a href="README_zh.md">🇨🇳 简体中文</a>
18
+ </p>
19
+
20
+ ---
21
+
22
+ </div>
23
+
24
+ ## ✨ 一分钟上手
25
+
26
+ ```bash
27
+ # 1. 安装
28
+ pip install fileflow-cli
29
+
30
+ # 2. 进入乱糟糟的下载目录
31
+ cd ~/Downloads
32
+
33
+ # 3. 生成配置文件
34
+ fileflow init
35
+
36
+ # 4. 预览整理效果(安全,不会动你的文件)
37
+ fileflow run .
38
+
39
+ # 5. 确认后执行整理
40
+ fileflow run . --force
41
+ ```
42
+
43
+ **搞定!** 你的文件被自动分类到 `Pictures/`、`Documents/`、`Code/`、`Videos/`、`Audio/` 等目录。
44
+
45
+ ---
46
+
47
+ ## 🎯 解决什么问题?
48
+
49
+ > **你的 Downloads 文件夹是不是像这样?**
50
+
51
+ ```
52
+ 📁 Downloads/
53
+ ├── IMG_2024.jpg
54
+ ├── project_report.pdf
55
+ ├── meeting_notes.docx
56
+ ├── screenshot.png
57
+ ├── vacation_photo.jpg
58
+ ├── budget_2024.xlsx
59
+ ├── app.py
60
+ ├── style.css
61
+ ├── video.mp4
62
+ ├── song.mp3
63
+ ├── archive.zip
64
+ ├── another_doc.pdf
65
+ ├── script.js
66
+ ├── logo.svg
67
+ ├── photo_from_2019.jpg
68
+ ...
69
+ ```
70
+
71
+ **整理后 →**
72
+
73
+ ```
74
+ 📁 Downloads/
75
+ ├── 📁 Pictures/jpg/vacation_photo.jpg
76
+ │ png/screenshot.png
77
+ │ svg/logo.svg
78
+ ├── 📁 Documents/pdf/project_report.pdf
79
+ │ docx/meeting_notes.docx
80
+ │ xlsx/budget_2024.xlsx
81
+ ├── 📁 Code/py/app.py
82
+ │ css/style.css
83
+ │ js/script.js
84
+ ├── 📁 Videos/mp4/video.mp4
85
+ ├── 📁 Audio/mp3/song.mp3
86
+ ├── 📁 Archives/zip/archive.zip
87
+ ```
88
+
89
+ **干净、有序、一目了然。**
90
+
91
+ ---
92
+
93
+ ## 🚀 功能特性
94
+
95
+ | 特性 | 说明 |
96
+ |------|------|
97
+ | 🎯 **YAML 规则引擎** | 声明式配置,想怎么分就怎么分 |
98
+ | 🔍 **预览模式** | 先看效果再执行,安全无副作用 |
99
+ | 📂 **6 种匹配方式** | 扩展名/通配符/正则/文件名包含/文件大小/组合 AND |
100
+ | 📦 **文件操作** | 移动/复制/删除,自动创建目录 |
101
+ | ⚡ **冲突处理** | 跳过/重命名/覆盖,策略可选 |
102
+ | ⏪ **支持撤销** | `fileflow undo` 一键回退 |
103
+ | 📊 **统计功能** | `fileflow stats` 查看整理记录 |
104
+ | 🔌 **可扩展** | 匹配器和操作都支持插件式注册 |
105
+ | 🎨 **终端美化** | Rich 进度条 + 彩色表格 |
106
+ | 🪶 **轻量依赖** | 只需 typer + rich + pyyaml |
107
+
108
+ ---
109
+
110
+ ## 📖 详细用法
111
+
112
+ ### 命令一览
113
+
114
+ ```bash
115
+ fileflow init # 🚀 生成默认 .fileflow.yaml
116
+ fileflow run . # 🔍 预览整理效果
117
+ fileflow run . --force # 📦 执行整理
118
+ fileflow validate # ✅ 验证配置文件
119
+ fileflow list-rules # 📋 查看规则列表
120
+ fileflow stats # 📊 查看统计信息
121
+ fileflow undo # ⏪ 撤销最近操作
122
+ fileflow --help # 📖 查看帮助
123
+ ```
124
+
125
+ ### 常用选项
126
+
127
+ | 选项 | 说明 |
128
+ |------|------|
129
+ | `--config, -c` | 指定配置文件 |
130
+ | `--dry-run, -n` | 仅预览模式 |
131
+ | `--force, -f` | 跳过预览,直接执行 |
132
+ | `--yes, -y` | 跳过所有确认提示 |
133
+ | `--no-recursive` | 不扫描子目录 |
134
+ | `--no-progress` | 不显示进度条 |
135
+ | `--verbose, -v` | 详细输出 |
136
+ | `--version, -V` | 显示版本 |
137
+
138
+ ### 示例
139
+
140
+ ```bash
141
+ # 整理桌面
142
+ fileflow run ~/Desktop
143
+
144
+ # 使用自定义配置
145
+ fileflow run . --config ~/my-rules.yaml
146
+
147
+ # 不递归子目录
148
+ fileflow run . --force --no-recursive
149
+
150
+ # 只预览,不确认
151
+ fileflow run . --dry-run -y
152
+
153
+ # 撤销最近 3 次操作
154
+ fileflow undo --steps 3
155
+
156
+ # 撤销所有操作
157
+ fileflow undo --all
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 📝 配置文件 (.fileflow.yaml)
163
+
164
+ ```yaml
165
+ version: "1.0"
166
+
167
+ settings:
168
+ dry_run_by_default: true # 默认预览模式
169
+ on_conflict: "skip" # skip | rename | overwrite
170
+ create_target_dirs: true
171
+
172
+ rules:
173
+ - name: "整理图片"
174
+ description: "按扩展名分类图片"
175
+ match:
176
+ extensions: [".jpg", ".jpeg", ".png", ".gif", ".svg", ".bmp"]
177
+ action: move
178
+ target: "Pictures/{ext_no_dot}/{filename}"
179
+
180
+ - name: "整理文档"
181
+ match:
182
+ extensions: [".pdf", ".doc", ".docx", ".xls", ".xlsx"]
183
+ max_size_mb: 50 # 忽略超过 50MB 的文件
184
+ action: move
185
+ target: "Documents/{ext_no_dot}/{filename}"
186
+
187
+ - name: "清理旧日志"
188
+ match:
189
+ extensions: [".log"]
190
+ min_size_mb: 100 # 只处理超过 100MB 的日志
191
+ action: delete
192
+ enabled: false # 默认禁用,需手动启用
193
+ ```
194
+
195
+ ### 📂 路径模板变量
196
+
197
+ | 变量 | 说明 | 示例值 |
198
+ |------|------|--------|
199
+ | `{filename}` | 完整文件名 | `report.pdf` |
200
+ | `{name}` | 文件名(无扩展名) | `report` |
201
+ | `{ext_no_dot}` | 扩展名(无点,推荐目录用) | `pdf` |
202
+ | `{ext}` | 扩展名(含点) | `.pdf` |
203
+ | `{year}` | 4 位年份 | `2026` |
204
+ | `{month}` | 2 位月份 | `07` |
205
+ | `{day}` | 2 位日期 | `13` |
206
+
207
+ > **推荐使用 `{ext_no_dot}` 作为目录名**,如 `Documents/pdf/report.pdf`,而不是 `Documents/.pdf/report.pdf`。
208
+
209
+ ---
210
+
211
+ ## 🏗 项目架构
212
+
213
+ ```
214
+ fileflow/
215
+ ├── src/fileflow/
216
+ │ ├── cli.py # CLI 命令 (Typer)
217
+ │ ├── config.py # YAML 配置加载 & 验证
218
+ │ ├── engine.py # 核心引擎 (扫描→匹配→执行)
219
+ │ ├── history.py # 操作历史 & Undo
220
+ │ ├── rules.py # 规则数据模型
221
+ │ ├── matchers.py # 匹配器注册表 + 6 种内置匹配器
222
+ │ ├── actions.py # 文件操作注册表 (move/copy/delete)
223
+ │ ├── templates.py # 路径模板变量解析
224
+ │ └── report.py # Rich 终端美化输出
225
+ ├── tests/ # 76 项单元测试
226
+ ├── .github/ # CI/CD 自动化
227
+ └── pyproject.toml # 项目配置
228
+ ```
229
+
230
+ ### 🧩 设计亮点
231
+
232
+ **匹配器注册表模式** — 新增匹配器只需注册,无需修改其他代码:
233
+
234
+ ```python
235
+ @register("my_matcher")
236
+ class MyMatcher(Matcher):
237
+ def __call__(self, path: Path) -> bool:
238
+ return path.suffix == ".xyz"
239
+ ```
240
+
241
+ ---
242
+
243
+ ## 🧪 开发 & 测试
244
+
245
+ ```bash
246
+ git clone https://github.com/Linger668/fileflow.git
247
+ cd fileflow
248
+ pip install -e ".[dev]"
249
+
250
+ # 运行测试
251
+ pytest
252
+
253
+ # 代码检查
254
+ ruff check src/
255
+ ruff format src/
256
+ mypy src/
257
+ ```
258
+
259
+ ---
260
+
261
+ ## 🤝 贡献
262
+
263
+ 欢迎提交 [Issue](https://github.com/Linger668/fileflow/issues) 和 [PR](https://github.com/Linger668/fileflow/pulls)!
264
+
265
+ **新手友好** 👉 查看 [good first issues](https://github.com/Linger668/fileflow/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
266
+
267
+ ---
268
+
269
+ ## 📄 许可证
270
+
271
+ [MIT](LICENSE) © 2026 Yuluo
272
+
273
+ ---
274
+
275
+ <div align="center">
276
+
277
+ **如果 FileFlow 帮到了你,请给它 ⭐ 支持一下!** 🌟
278
+
279
+ [![GitHub Stars](https://img.shields.io/github/stars/Linger668/fileflow?style=social)](https://github.com/Linger668/fileflow)
280
+
281
+ </div>
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fileflow-cli"
7
- version = "0.1.0"
7
+ version = "0.2.1"
8
8
  description = "🧹 智能文件整理器 — YAML 规则引擎驱动的 CLI 文件分类/移动/清理工具"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
- license = { text = "MIT" }
11
+ license = "MIT"
12
12
  authors = [
13
13
  { name = "Yuluo", email = "lingeryuluo@gmail.com" },
14
14
  ]
@@ -18,7 +18,6 @@ classifiers = [
18
18
  "Environment :: Console",
19
19
  "Intended Audience :: Developers",
20
20
  "Intended Audience :: End Users/Desktop",
21
- "License :: OSI Approved :: MIT License",
22
21
  "Operating System :: OS Independent",
23
22
  "Programming Language :: Python :: 3",
24
23
  "Programming Language :: Python :: 3.10",
@@ -72,6 +71,11 @@ python_version = "3.10"
72
71
  exclude = ["tests/"]
73
72
  ignore_missing_imports = true
74
73
 
74
+ # Typer decorators don't have type stubs
75
+ [[tool.mypy.overrides]]
76
+ module = "fileflow.cli"
77
+ disable_error_code = ["untyped-decorator"]
78
+
75
79
  [tool.pytest.ini_options]
76
80
  testpaths = ["tests"]
77
81
  python_files = ["test_*.py"]
@@ -1,3 +1,3 @@
1
1
  """FileFlow — 智能文件整理器."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.1"
@@ -9,9 +9,9 @@
9
9
  from __future__ import annotations
10
10
 
11
11
  import shutil
12
+ from collections.abc import Callable
12
13
  from enum import Enum
13
14
  from pathlib import Path
14
- from typing import Callable
15
15
 
16
16
  from .templates import resolve_path
17
17