Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we get some form of Format Macro? #155

Open
TheEmeraldBee opened this issue Jun 10, 2023 · 1 comment
Open

Could we get some form of Format Macro? #155

TheEmeraldBee opened this issue Jun 10, 2023 · 1 comment

Comments

@TheEmeraldBee
Copy link

TheEmeraldBee commented Jun 10, 2023

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.

@autarch
Copy link

autarch commented Jan 28, 2024

Just a drive-by comment, but this seems like a thing that could be done in a separate crate relatively easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants