refactor(core,shim): 统一基于 thiserror 的错误体系
- 移除 anyhow,使用 thiserror 定义强类型 Error 枚举 - 支持 #[from] 自动转换 mlua::Error,关键路径保留源码与上下文 - LuaRuntimeBuilder 采用惰性错误收集,简化链式初始化调用 - MirrorRegistry 实现规范化 FromLuaConversionError 错误转换
This commit is contained in:
+4
-14
@@ -1,37 +1,27 @@
|
||||
-- commands/commands.lua
|
||||
function command(mod_path)
|
||||
-- 无论输入 "a/b/c" 还是 "a\b\c",统一替换为标准的 "a.b.c"
|
||||
local normalized = mod_path:gsub("[/\\]", ".")
|
||||
|
||||
return {
|
||||
__is_lazy_command = true,
|
||||
module = normalized
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
-- 1. 单文件子命令 (commands/use.lua)
|
||||
["use"] = {
|
||||
description = "Switch the active version of a tool",
|
||||
handler = command("use")
|
||||
module = mr.command("use")
|
||||
},
|
||||
|
||||
-- 2. 单文件子命令 (commands/list.lua)
|
||||
["list"] = {
|
||||
description = "List available and currently activated versions",
|
||||
handler = command("list")
|
||||
module = mr.command("list")
|
||||
},
|
||||
|
||||
-- 3. 复杂多文件子命令 (加载 commands/log/init.lua)
|
||||
["log"] = {
|
||||
description = "View or configure mirror runtime logs",
|
||||
handler = command("log")
|
||||
module = mr.command("log")
|
||||
},
|
||||
|
||||
-- 4. 支持别名快捷映射 (例如 mr ls 等价于 mr list)
|
||||
["ls"] = {
|
||||
description = "Alias for list",
|
||||
handler = command("list")
|
||||
module = mr.command("list")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user