go-pretty
go-pretty copied to clipboard
Custom top and bottom table style
First, thanks for the great library. It is excellent.
It would be nice to be able to customize the first and last rows of the table different from the middle ones.
From what I've seen, MiddleHorizontal
(t.Style().Box.MiddleHorizontal
) controls the style of all horizontal lines. However, it would be nice to have independent Top
and Bottom
options.
These options could generate the following tables, which I didn't get in the current settings:
# FIRST NAME LAST NAME SALARY <- no top line
----- ------------ ----------- -------- -----------------------------
1 Arya Stark 3000
20 Jon Snow 2000 You know nothing, Jon Snow!
300 Tyrion Lannister 5000
----- ------------ ----------- -------- -----------------------------
TOTAL 10000
----- ------------ ----------- -------- ----------------------------- <- with bottom line
=====+============+===========+========+============================= <- diferrent styles
# | FIRST NAME | LAST NAME | SALARY |
-----+------------+-----------+--------+----------------------------- <- diferrent styles
1 | Arya | Stark | 3000 |
20 | Jon | Snow | 2000 | You know nothing, Jon Snow!
300 | Tyrion | Lannister | 5000 |
-----+------------+-----------+--------+-----------------------------
| | TOTAL | 10000 |
=====+============+===========+========+=============================
^^^^^+^^^^^^^^^^^^+^^^^^^^^^^^+^^^^^^^^+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- diferrent styles
# | FIRST NAME | LAST NAME | SALARY |
-----+------------+-----------+--------+----------------------------- <- diferrent styles
1 | Arya | Stark | 3000 |
20 | Jon | Snow | 2000 | You know nothing, Jon Snow!
300 | Tyrion | Lannister | 5000 |
-----+------------+-----------+--------+-----------------------------
| | TOTAL | 10000 |
~~~~~+~~~~~~~~~~~~+~~~~~~~~~~~+~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <- diferrent styles
With this feature, custom styles would become more generic.
This is possible to do. Will try to get this implemented.
The implementation is complex simply because this introduces a LOT of edge cases (literally). Just thought I'd let you know to not expect this soon. Will update this thread when I make some progress.
Hey @manoelmozzer ... I honestly tried to make this customization work, but the more I worked on it, the more it felt like a lot of code quality/simplicity/maintainability had to be sacrificed to make this work.
I have code that can stylize Title/Header/Rows/Footers all separately in their own individual styles. But this change required a bunch of backward-incompatible changes and a major version bump along with making the code really hard to read/reason/maintain.
I'll leave this issue open, and if a lot more folks ask for this feature, I'll see what I can do. But for now, I'm gonna stop working on this. Sorry! 😞
No problem, thanks for your try. Anyway, your library is great. xD
RST grid table can be rendered if this feature is implemented.