feat: 目录结构迁移优化
- 将 MirrorRegistry MirrorTarget 迁移到 model.rs - TargetConfig 独立实现 FromLua,解耦反序列化与业务校验 - mirror—shim 新增 command.rs 并将 to_command 移动到 command.rs - 其他优化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
use mirror_core::MirrorTarget;
|
||||
use std::ffi::OsString;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use tracing::debug;
|
||||
pub fn to_command<P>(spec: &MirrorTarget, target: P, final_args: &[OsString]) -> Command
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let mut cmd = Command::new(target.as_ref());
|
||||
|
||||
// 2. 传入预打平的别名字典,查表并展开所有以 `mr:` 为前缀的别名
|
||||
// let final_args = self.resolve_args(combined_args);
|
||||
debug!("拼接后的命令行参数{:?}", final_args);
|
||||
// 3. 将解析展开后的无环参数一次性注入 Command
|
||||
cmd.args(final_args);
|
||||
|
||||
// 4. 注入配置好的环境变量
|
||||
for (key, val) in &spec.env {
|
||||
// 直接应用环境变量(Lua 端已经处理好字符串拼接或列表合并)
|
||||
cmd.env(key, val);
|
||||
}
|
||||
|
||||
cmd
|
||||
}
|
||||
Reference in New Issue
Block a user