@@ -81,6 +81,11 @@ fn format_size(bytes: u64) -> String {
8181 }
8282}
8383
84+ /// Format a log file count label.
85+ fn log_file_label ( count : usize ) -> & ' static str {
86+ if count == 1 { "log file" } else { "log files" }
87+ }
88+
8489impl LogsCli {
8590 /// Run the logs command.
8691 pub async fn run ( self ) -> Result < ( ) > {
@@ -344,8 +349,9 @@ impl LogsCli {
344349
345350 if cleared > 0 {
346351 println ! (
347- "Cleared {} log file(s) ({}) older than {} days." ,
352+ "Cleared {} {} ({}) older than {} days." ,
348353 cleared,
354+ log_file_label( cleared) ,
349355 format_size( cleared_bytes) ,
350356 self . keep_days
351357 ) ;
@@ -406,6 +412,13 @@ mod tests {
406412 assert_eq ! ( format_size( MB ) , "1.00 MB" ) ;
407413 }
408414
415+ #[ test]
416+ fn test_log_file_label_singular_and_plural ( ) {
417+ assert_eq ! ( log_file_label( 1 ) , "log file" ) ;
418+ assert_eq ! ( log_file_label( 0 ) , "log files" ) ;
419+ assert_eq ! ( log_file_label( 2 ) , "log files" ) ;
420+ }
421+
409422 // =========================================================================
410423 // Tests for LogsCli default values
411424 // =========================================================================
0 commit comments