refactor: 迁移至 bashly CLI 与功能域模块结构
- CLI 定义迁移至 src/bashly.yml(bashly 1.4 生成参数解析),入口收敛为 src/root_command.sh - 源码按功能域重组:config/storage/integrate/media/pipeline,消除扁平散落 - 新增零依赖测试框架 tests/(123 用例)与 CI 流水线(lint + test + build + 产物一致性) - build.sh 支持版本单一来源注入与 --check 产物校验;新增 lint.sh(bash -n + shellcheck 零容忍) - 删除旧单文件 media_organizer.sh 与旧扁平模块
This commit is contained in:
1 parent
d978a13a83
commit
0df07ad0ae
48 files changed
+5813
-6812
No files matched your search
@@ -0,0 +1,82 @@
|
||||
# ============================================================================
|
||||
# bashly CLI 定义
|
||||
#
|
||||
# 迁移说明(bashly 1.4 能力边界):
|
||||
# - flag 不支持可选参数 → --list-cache / --export-map 为纯 flag:
|
||||
# · --list-cache 的可选关键词经位置参数传递(root_command 中映射)
|
||||
# · --export-map 使用默认/配置目录(config.json 的 EXPORT_MAP_DIR)
|
||||
# · 原 --list-cache=KEY / --export-map=DIR 的 = 形式不再支持
|
||||
# - 位置参数与 flag 的 arg 均设置 expose: true(生成 arg_xxx/flag_xxx 变量)
|
||||
# - 互斥用 conflicts(bashly 报错退出码 1;原 _usage_error 为 2)
|
||||
# ============================================================================
|
||||
name: media_organizer
|
||||
help: |-
|
||||
Jellyfin 媒体库硬链接整理脚本 v9.6
|
||||
|
||||
自动化整理媒体库:通过 TMDB API 识别电影与电视剧,并用硬链接创建
|
||||
标准化的目录结构。支持 AI 辅助识别、全量缓存、特典映射、季数偏移、
|
||||
Music Videos 音乐视频类目、配置按类目分区。
|
||||
|
||||
模式(一次调用只取其一):
|
||||
<源目录> <目的目录> 正常整理(使用缓存)
|
||||
--update-cache <源目录> <目的目录> 整理并强制重取对应缓存
|
||||
--update-cache <源目录> 仅更新缓存,不整理
|
||||
--list-cache [关键词] 列出缓存条目(可选关键词过滤)
|
||||
--export-map [目录] 生成源→目标对照表 markdown
|
||||
--rerun <账本文件> 手动纠错重跑(不重新识别)
|
||||
|
||||
配置优先级:CLI > 环境变量 > config.json > 默认值
|
||||
|
||||
示例:
|
||||
dist/media_organizer /downloads /media
|
||||
dist/media_organizer --dry-run /downloads /media
|
||||
dist/media_organizer --list-cache 刀剑
|
||||
version: 9.6
|
||||
|
||||
args:
|
||||
- name: source_dir
|
||||
help: 源目录(--list-cache 模式下作为可选关键词)
|
||||
- name: destination_dir
|
||||
help: 目的目录
|
||||
|
||||
flags:
|
||||
- long: --automated
|
||||
short: -a
|
||||
help: 自动化模式(写入日志,跳过无法处理项目)
|
||||
conflicts:
|
||||
- --list-cache
|
||||
- long: --no-automated
|
||||
help: 取消自动化模式(覆盖环境变量/config.json 设置)
|
||||
- long: --dry-run
|
||||
help: 干运行:不创建链接、不写缓存、不写日志(网络请求照常但不落盘)
|
||||
conflicts:
|
||||
- --list-cache
|
||||
- long: --no-dry-run
|
||||
help: 取消干运行(覆盖环境变量/config.json 设置)
|
||||
- long: --refresh-cache
|
||||
help: 清空 TMDB 缓存后执行(保留特典映射等脚本学习数据;可与任意模式叠加)
|
||||
- long: --update-cache
|
||||
help: 强制重取对应缓存条目(与 --list-cache 互斥)
|
||||
conflicts:
|
||||
- --list-cache
|
||||
- long: --list-cache
|
||||
help: 列出缓存条目(可选关键词经位置参数传递)
|
||||
conflicts:
|
||||
- --update-cache
|
||||
- long: --export-map
|
||||
help: 生成源→目标对照表 markdown(目录经 config.json 的 EXPORT_MAP_DIR 或默认 mo_map)
|
||||
- long: --rerun
|
||||
arg: ledger_file
|
||||
help: 手动纠错重跑:按账本中 action="rerun" 的条目重新硬链接(可叠加 --dry-run 预览)
|
||||
- long: --src-dir
|
||||
arg: src
|
||||
help: 指定源目录(与位置参数互斥)
|
||||
- long: --dest-dir
|
||||
arg: dest
|
||||
help: 指定目的目录(与位置参数互斥)
|
||||
|
||||
# 复杂校验(bashly 声明式表达不了的,在 root_command 中实现):
|
||||
# - 目录只能通过一种方式指定:2 个位置参数,或 --src-dir + --dest-dir
|
||||
# - --list-cache 不接受目的目录参数;--dry-run/--automated 不能与 --list-cache 同用
|
||||
# - --update-cache 需要源目录
|
||||
# - 整理模式需要源目录与目的目录
|
||||
Reference in new issue
Block a user