diff --git a/src/builtins/ls.rs b/src/builtins/ls.rs index 09372c2..1c0e019 100644 --- a/src/builtins/ls.rs +++ b/src/builtins/ls.rs @@ -37,16 +37,18 @@ impl Builtin for Ls { file_type = "link" } println!( - "{:} | {:4} | {}", - right_padding(&file_name, 16), - file_type, - metadata.len() + "{}", + format_line(&right_padding(&file_name, 16), file_type, metadata.len()) ) } Ok(()) } } +fn format_line(right_padding: &str, file_type: &str, file_size: u64) -> String { + format!("{:} | {:4} | {}", right_padding, file_type, file_size) +} + fn right_padding(s: &str, max: usize) -> String { let mut tmp = String::from_str(s).unwrap(); for _ in tmp.len()..max {