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
13
src/main.rs
13
src/main.rs
@ -568,18 +568,23 @@ fn run() -> Result<()> {
|
|||||||
if let Some(_) = app_matches.values_of("list languages") {
|
if let Some(_) = app_matches.values_of("list languages") {
|
||||||
let languages = assets.syntax_set.syntaxes();
|
let languages = assets.syntax_set.syntaxes();
|
||||||
|
|
||||||
for lang in languages {
|
let longest = match languages.iter()
|
||||||
print!("{}\t", lang.name);
|
.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() {
|
for i in 0..lang.file_extensions.len() {
|
||||||
print!("{}", lang.file_extensions[i]);
|
print!("{}", lang.file_extensions[i]);
|
||||||
|
|
||||||
if i < lang.file_extensions.len() - 1 {
|
if i < lang.file_extensions.len() - 1 {
|
||||||
print!(", ");
|
print!(", ");
|
||||||
} else {
|
|
||||||
println!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
Loading…
Reference in New Issue
Block a user