add blank lines and protocol version to table

This commit is contained in:
LordMZTE 2020-11-24 17:37:55 +01:00
parent 2de875d9c7
commit d6710cfac7
2 changed files with 17 additions and 0 deletions

View File

@ -132,12 +132,17 @@ async fn main() -> Result<()> {
none_if_empty!(remove_formatting(&player_sample)),
);
table.blank();
table.opt_small_entry(
"Server Version",
none_if_empty!(remove_formatting(&response.version.name)),
);
table.small_entry("Online Players", &response.players.online);
table.small_entry("Max Players", &response.players.max);
table.small_entry("Protocol Version", &response.version.protocol);
table.blank();
table.opt_big_entry(
"Mods",

View File

@ -25,6 +25,10 @@ impl Table {
Default::default()
}
pub fn blank(&mut self) {
self.entries.push(Box::new(BlankTableEntry));
}
pub fn small_entry(&mut self, name: impl ToString, val: impl ToString) {
let name = name.to_string();
self.set_small_width(name.len());
@ -138,3 +142,11 @@ impl TableEntry for OptBigTableEntry {
}
}
}
pub struct BlankTableEntry;
impl TableEntry for BlankTableEntry {
fn print(&self, out: &mut dyn Write, _: &Table) -> io::Result<()> {
out.write(b"\n").map(|_| ())
}
}