mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 02:52:47 +08:00
feat(cli): document SENBEI_LANG in --help
The help now names the display-language variable, its values, the fallback to the system language, and that JSON and saved logs stay English. It is printed between the resource limits and the exit codes, in every language.
This commit is contained in:
1 parent
4853fe22c0
commit
3b28f1aaa4
8 files changed
+33
No files matched your search
@@ -466,6 +466,7 @@ fn print_help() {
|
||||
entries: defaults.max_entries,
|
||||
depth: defaults.max_depth,
|
||||
},
|
||||
Cli::HelpLanguage,
|
||||
Cli::HelpExitCodes,
|
||||
] {
|
||||
println!("{}", block.localize(lang));
|
||||
|
||||
@@ -64,6 +64,20 @@ fn usage_errors_and_help_follow_the_language() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_documents_the_language_variable_in_every_language() {
|
||||
for lang in Lang::ALL {
|
||||
let output = senbei(lang.tag()).arg("--help").output().unwrap();
|
||||
assert!(output.status.success());
|
||||
let help = text(&output.stdout);
|
||||
assert!(
|
||||
help.contains(&*Cli::HelpLanguage.localize(lang)),
|
||||
"{lang:?}"
|
||||
);
|
||||
assert!(help.contains("SENBEI_LANG"), "{lang:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_language_falls_back_to_english() {
|
||||
for value in ["fr", "C", "x-unknown"] {
|
||||
|
||||
@@ -445,6 +445,8 @@ pub enum Cli {
|
||||
depth: usize,
|
||||
},
|
||||
HelpExitCodes,
|
||||
/// `SENBEI_LANG`: the display language and what stays English.
|
||||
HelpLanguage,
|
||||
// -- text report ------------------------------------------------------
|
||||
ReportScanHeading,
|
||||
ReportScan {
|
||||
|
||||
@@ -249,6 +249,9 @@ pub(crate) fn cli(cli: &Cli) -> Cow<'static, str> {
|
||||
\x20 Limits are checked before extraction/allocation; they are not a peak-RSS cap."
|
||||
)
|
||||
.into(),
|
||||
Cli::HelpLanguage => " SENBEI_LANG display language: en, zh-CN, zh-TW, ja, or ko. Unset, the\n\
|
||||
\x20 system language is used. JSON and saved logs stay English."
|
||||
.into(),
|
||||
Cli::HelpExitCodes => " Exit codes: 0 success, 1 a target failed (or a suspect with\n\
|
||||
\x20 --strict-integrity), 2 the command line was rejected."
|
||||
.into(),
|
||||
|
||||
@@ -248,6 +248,9 @@ pub(crate) fn cli(cli: &Cli) -> Cow<'static, str> {
|
||||
\x20 上限は展開・割り当て前に検査されます。ピークRSSの上限ではありません。"
|
||||
)
|
||||
.into(),
|
||||
Cli::HelpLanguage => " SENBEI_LANG 表示言語: en、zh-CN、zh-TW、ja、またはko。未設定時は\n\
|
||||
\x20 システムの言語を使用します。JSONと保存されるログは常に英語です。"
|
||||
.into(),
|
||||
Cli::HelpExitCodes => " 終了コード: 0 成功、1 対象の失敗 (--strict-integrity時の要注意を含む)、\n\
|
||||
\x20 2 コマンドライン引数の却下。"
|
||||
.into(),
|
||||
|
||||
@@ -374,6 +374,10 @@ pub(crate) fn cli(cli: &Cli) -> Cow<'static, str> {
|
||||
\x20 제한은 추출/할당 전에 확인되며 최대 RSS 상한선이 아닙니다."
|
||||
)
|
||||
.into(),
|
||||
Cli::HelpLanguage => " SENBEI_LANG 표시 언어: en, zh-CN, zh-TW, ja 또는 ko. 설정하지 않으면\n\
|
||||
\x20 시스템 언어를 사용합니다. JSON 및 저장된 로그는 영어로\n\
|
||||
\x20 유지됩니다."
|
||||
.into(),
|
||||
Cli::HelpExitCodes => " 종료 코드: 0 성공, 1 대상 실패 (--strict-integrity 사용 시 의심됨 포함),\n\
|
||||
\x20 2 명령줄이 거부됨."
|
||||
.into(),
|
||||
|
||||
@@ -246,6 +246,9 @@ pub(crate) fn cli(cli: &Cli) -> Cow<'static, str> {
|
||||
\x20 提取或分配前会检查限制;这些限制不是内存使用峰值的上限。"
|
||||
)
|
||||
.into(),
|
||||
Cli::HelpLanguage => " SENBEI_LANG 显示语言:en、zh-CN、zh-TW、ja 或 ko。未设置时使用系统\n\
|
||||
\x20 语言。JSON 与保存的日志始终使用英文。"
|
||||
.into(),
|
||||
Cli::HelpExitCodes => " 退出代码:0 成功,1 有目标失败(或启用 --strict-integrity 时存在可疑\n\
|
||||
\x20 项),2 命令行参数被拒绝。"
|
||||
.into(),
|
||||
|
||||
@@ -244,6 +244,9 @@ pub(crate) fn cli(cli: &Cli) -> Cow<'static, str> {
|
||||
\x20 系統會在解壓縮或配置記憶體前檢查限制;這些限制並非尖峰記憶體使用量上限。"
|
||||
)
|
||||
.into(),
|
||||
Cli::HelpLanguage => " SENBEI_LANG 顯示語言:en、zh-CN、zh-TW、ja 或 ko。未設定時會使用\n\
|
||||
\x20 系統語言。JSON 與儲存的記錄檔維持英文。"
|
||||
.into(),
|
||||
Cli::HelpExitCodes => " 結束代碼:0 成功,1 目標失敗(或啟用 --strict-integrity 時有可疑項),\n\
|
||||
\x20 2 命令列參數遭拒。"
|
||||
.into(),
|
||||
|
||||
Reference in new issue
Block a user