From f68737298acd251bf4119e55ee2d6a01467df339 Mon Sep 17 00:00:00 2001 From: fdai7375 Date: Wed, 1 Feb 2023 11:21:35 +0100 Subject: [PATCH] feat: improve ls command output formatting --- src/builtins/ls.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/builtins/ls.rs b/src/builtins/ls.rs index 88a1895..d621b81 100644 --- a/src/builtins/ls.rs +++ b/src/builtins/ls.rs @@ -18,6 +18,11 @@ impl Builtin for Ls { //for entry in entries.by_ref().into_iter() {} + println!( + "{} | dir | size | modified |", + right_padding(" filename", 20) + ); + for entry in entries { let Ok(entry) = entry else { eprintln!("Couldn't get directory entry"); @@ -83,11 +88,11 @@ fn format_line( modified: DateTime, ) -> String { format!( - "{} | {:4} | {:6} | {}", + "{} | {:4} | {:6} | {} |", right_padding(file_name, max_name_len), file_type, format_filesize(file_size), - format_date(modified) + right_padding(&format_date(modified), 10) ) }