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

Add arbitrary separators to tables #97

Closed
guumaster opened this issue Apr 18, 2020 · 5 comments · Fixed by #101
Closed

Add arbitrary separators to tables #97

guumaster opened this issue Apr 18, 2020 · 5 comments · Fixed by #101
Assignees
Labels
enhancement New feature or request

Comments

@guumaster
Copy link

guumaster commented Apr 18, 2020

Is your feature request related to a problem? Please describe.
I would like to have the option to add a table row that is printed as a separator row. Like what happens with header and footer, but some way of programmatically add a new separator between any rows.

Describe the solution you'd like
Something like AddSeparator() to mark a line separator between rows.

Describe alternatives you've considered

Additional context
I'm trying to migrate my project hostctl to use go-pretty but this feature is needed to split content of each profile on the printed table.

@jedib0t
Copy link
Owner

jedib0t commented May 7, 2020

I think I understand your ask here, but can you share an example of how you'd like the output to look like?

@jedib0t
Copy link
Owner

jedib0t commented May 7, 2020

Never mind. I think this can be done. Will look into it.

@guumaster
Copy link
Author

Something like this:

+-----+------------+-----------+--------+-----------------------------+
|   # | FIRST NAME | LAST NAME | SALARY |                             |
+-----+------------+-----------+--------+-----------------------------+
|   1 | Arya       | Stark     |   3000 |                             |
|  20 | Jon        | Snow      |   2000 | You know nothing, Jon Snow! |
+-----+------------+-----------+--------+-----------------------------+
| 300 | Tyrion     | Lannister |   5000 |                             |
+-----+------------+-----------+--------+-----------------------------+
|     |            | TOTAL     |  10000 |                             |
+-----+------------+-----------+--------+-----------------------------+

Marking the line between Jon and Tyrion as separator with some method call

@jedib0t
Copy link
Owner

jedib0t commented May 8, 2020

Hey @guumaster, I've added support for appending Separator rows at will. However, please take a look at the caveats listed in the PR @ #101. The PR's description also contains sample code and output. Lemme know if this works, and if you need anything else.

Hope this helps! 👍

@jedib0t jedib0t self-assigned this May 8, 2020
@jedib0t jedib0t added the enhancement New feature or request label May 8, 2020
@guumaster
Copy link
Author

This is great. Thank you very much. 👍

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

Successfully merging a pull request may close this issue.

2 participants