prettytable-rs
prettytable-rs copied to clipboard
Could we get some form of Format Macro?
It would be pretty cool to see a way to make a format with a macro!
Something Like
let format = table_format!(
// This could be the title format
// C would signify that the cell goes here
Title->{
+===+===+
| C | C |
+===+===+
},
// The Other Formats
Row-> {
+---+---+
| C C |
+---+---+
}
);
// Then to make a table out of it
let mut table = table!(format,
["Hello World!", "This is a cool format tool"]
);
table.set_titles(row!["Cool Title", "Part 2"]);
table.print_tty(true);
Which would result in
+==============+============================+
| Cool Title | Part 2 |
+==============+============================+
| Hello World! | This is a cool format tool |
+--------------+----------------------------+
I'm not remotely familiar with how macro writing would work, but would this be possible, I'm happy to work through it, if interested.
Just a drive-by comment, but this seems like a thing that could be done in a separate crate relatively easily.