mirror of
https://github.com/sharkdp/bat
synced 2024-11-16 21:25:56 +00:00
Size language name column width to the length of the longest language.
This commit is contained in:
parent
9b0877102c
commit
438a9a99ed
15
src/main.rs
15
src/main.rs
@ -568,19 +568,24 @@ fn run() -> Result<()> {
|
||||
if let Some(_) = app_matches.values_of("list languages") {
|
||||
let languages = assets.syntax_set.syntaxes();
|
||||
|
||||
for lang in languages {
|
||||
print!("{}\t", lang.name);
|
||||
let longest = match languages.iter()
|
||||
.map(|s| s.name.len())
|
||||
.max() {
|
||||
Some(longlang) => longlang,
|
||||
None => 32,
|
||||
};
|
||||
|
||||
for lang in languages {
|
||||
print!("{:width$} | ", lang.name, width = longest);
|
||||
for i in 0..lang.file_extensions.len() {
|
||||
print!("{}", lang.file_extensions[i]);
|
||||
|
||||
if i < lang.file_extensions.len() - 1 {
|
||||
print!(", ");
|
||||
} else {
|
||||
}
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user