- 将 MirrorRegistry MirrorTarget 迁移到 model.rs - TargetConfig 独立实现 FromLua,解耦反序列化与业务校验 - mirror—shim 新增 command.rs 并将 to_command 移动到 command.rs - 其他优化
25 lines
624 B
Rust
25 lines
624 B
Rust
use mirror_core::Result;
|
|
use mlua::{Lua, Table, Value};
|
|
|
|
/// 仅存在于 CLI 侧的 DSL 扩展函数
|
|
pub fn register_mr_command(lua: &Lua) -> Result<()> {
|
|
let globals = lua.globals();
|
|
|
|
let mr_table: Table = match globals.get("mr")? {
|
|
Value::Table(tbl) => tbl,
|
|
_ => {
|
|
let tbl = lua.create_table()?;
|
|
globals.set("mr", &tbl)?;
|
|
tbl
|
|
}
|
|
};
|
|
|
|
let command_fn = lua.create_function(|_lua, mod_path: String| {
|
|
let normalized = mod_path.replace(['/', '\\'], ".");
|
|
Ok(normalized)
|
|
})?;
|
|
|
|
mr_table.set("command", command_fn)?;
|
|
Ok(())
|
|
}
|