fix(cli): 程序名只替换模板占位符,不再改写用户数据(M82 r2 复审 P2)
r1 把 `rename` 套在**插值后的整条文本**上,于是用户数据被改坏:账户名恰好是 `ull` 会变成
`unlucky-launcher`,路径 `D:/tmp/ull/.ULL/...` 会变成 `D:/tmp/unlucky-launcher/.ULL/...`,
回显的子命令 `ull` 也会被改名。
改成模板占位符:文案里写 `%prog%`,**只在渲染时**(print_report / print_error / 帮助)替换成
argv[0] 的 basename。占位符只存在于静态模板里,插值进来的账户名 / 路径 / 子命令碰不到它。
用 `%prog%` 而不是 `{prog}`:这些模板要活在 `format!` 里,`{prog}` 会被 format! 当成参数名
编译失败。
同时补上 r1 漏的反方向:**stdout 的正常输出**(Report.human 与 warnings)现在也做替换,
以前只有 stderr 的错误做了,两边不一致。
回归测试:`user_data_that_says_ull_is_never_rewritten` 断言「账户名 `ull`」「路径 `\ull\`」
「未知命令 `ull`」在 fill 之后逐字不变。
占位符替换覆盖 21 个文件的 63 处文案;测试夹具里形如 `ull-mcp-diagnose-<pid>` 的临时目录名
已回滚为字面量(那不是文案)。
This commit is contained in:
1 parent
c9e6236a87
commit
2f8bbd1746
20 files changed
+99
-105
No files matched your search
@@ -75,14 +75,14 @@ pub(crate) fn map_auth_error(error: unlucky_core::auth::AuthError) -> CliError {
|
||||
let hint = match &error {
|
||||
AuthError::Canceled => Some("登录被取消,可以重跑一次".to_string()),
|
||||
AuthError::Timeout { .. } => {
|
||||
Some("重新执行 `ull accounts add msa` 拿新的用户码".to_string())
|
||||
Some("重新执行 `%prog% accounts add msa` 拿新的用户码".to_string())
|
||||
}
|
||||
AuthError::CredentialExpired => Some("重新登录:ull accounts add msa".to_string()),
|
||||
AuthError::CredentialExpired => Some("重新登录:%prog% accounts add msa".to_string()),
|
||||
AuthError::Unsupported(_) => {
|
||||
Some("微软登录需要设置 ULL_MSA_CLIENT_ID(Azure 公共客户端 id)".to_string())
|
||||
}
|
||||
AuthError::Conflict { .. } => Some("用 `ull accounts list` 查看已有账户".to_string()),
|
||||
AuthError::NotFound { .. } => Some("用 `ull accounts list` 查看账户名".to_string()),
|
||||
AuthError::Conflict { .. } => Some("用 `%prog% accounts list` 查看已有账户".to_string()),
|
||||
AuthError::NotFound { .. } => Some("用 `%prog% accounts list` 查看账户名".to_string()),
|
||||
AuthError::Denied { code, .. } if code == "no_profile" || code == "no_license" => {
|
||||
Some("去 minecraft.net 检查该账号的 Java 版拥有权与档案".to_string())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user