Skip to content

Commit 8534ea3

Browse files
committed
fix(logs): 修正清理日志单复数文案
1 parent 7954d02 commit 8534ea3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/cortex-cli/src/logs_cmd.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ fn format_size(bytes: u64) -> String {
8181
}
8282
}
8383

84+
fn log_file_label(count: usize) -> &'static str {
85+
if count == 1 { "log file" } else { "log files" }
86+
}
87+
8488
impl LogsCli {
8589
/// Run the logs command.
8690
pub async fn run(self) -> Result<()> {
@@ -344,8 +348,9 @@ impl LogsCli {
344348

345349
if cleared > 0 {
346350
println!(
347-
"Cleared {} log file(s) ({}) older than {} days.",
351+
"Cleared {} {} ({}) older than {} days.",
348352
cleared,
353+
log_file_label(cleared),
349354
format_size(cleared_bytes),
350355
self.keep_days
351356
);
@@ -406,6 +411,13 @@ mod tests {
406411
assert_eq!(format_size(MB), "1.00 MB");
407412
}
408413

414+
#[test]
415+
fn test_log_file_label() {
416+
assert_eq!(log_file_label(0), "log files");
417+
assert_eq!(log_file_label(1), "log file");
418+
assert_eq!(log_file_label(2), "log files");
419+
}
420+
409421
// =========================================================================
410422
// Tests for LogsCli default values
411423
// =========================================================================

0 commit comments

Comments
 (0)