mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-23 06:48:53 +01:00
Size language name column width to the length of the longest language.
This commit is contained in:
parent
9b0877102c
commit
438a9a99ed
13
src/main.rs
13
src/main.rs
@ -568,18 +568,23 @@ 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!();
|
||||
}
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
Loading…
Reference in New Issue
Block a user