|
@ -37,16 +37,18 @@ impl Builtin for Ls { |
|
|
file_type = "link"
|
|
|
file_type = "link"
|
|
|
}
|
|
|
}
|
|
|
println!(
|
|
|
println!(
|
|
|
"{:} | {:4} | {}",
|
|
|
|
|
|
right_padding(&file_name, 16),
|
|
|
|
|
|
file_type,
|
|
|
|
|
|
metadata.len()
|
|
|
|
|
|
|
|
|
"{}",
|
|
|
|
|
|
format_line(&right_padding(&file_name, 16), file_type, metadata.len())
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
Ok(())
|
|
|
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 {
|
|
|
fn right_padding(s: &str, max: usize) -> String {
|
|
|
let mut tmp = String::from_str(s).unwrap();
|
|
|
let mut tmp = String::from_str(s).unwrap();
|
|
|
for _ in tmp.len()..max {
|
|
|
for _ in tmp.len()..max {
|
|
|