Skip to content

Commit

Permalink
logo and info side by side
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh authored Sep 19, 2018
1 parent 8062d92 commit e19fb33
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ impl fmt::Display for Info {
s.push_str(&("Number of lines: ".blue().bold().to_string() + &format!("{}\n", self.number_of_lines)));
s.push_str(&("License: ".blue().bold().to_string() + &format!("{}\n", self.license)));
s.push_str(&self.get_ascii().blue().bold().to_string());
write!(f, "{}", s)

let logo= self.get_ascii();
let mut lines = s.lines();
let left_pad = logo.lines().map(|l| l.len()).max().unwrap_or(0);
let mut o = String::new();
for a in logo.lines() {
let b = match lines.next() {
Some(line) => line,
None => "",
};
o.push_str(&format!("{:width$} {}\n", a, b, width = left_pad));
}

write!(f, "{}", o)
}
}

Expand Down

0 comments on commit e19fb33

Please sign in to comment.