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

[propose] Allow better customization of individual chars #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfromaniello
Copy link

This change is inspired by node.js's https://github.com/Automattic/cli-table which allows to configure more separator characters to allow the user to use a wider scope of ascii characters.

By default it still render as before and still has the same 3 methods for customizing the characters.

I am introducing a new method called SetSeparators() which receives an struct with all separators characters.

I am also exposing Themes.Default, Themes.CliTable, Themes.CliTableDouble.

Example with Themes.Default (or by not setting the separators):

+------------+-----------+---------+
| FIRST NAME | LAST NAME |   SSN   |
+------------+-----------+---------+
| John       | Barry     | 123456  |
+------------+-----------+---------+
| Kathy      | Smith     | 687987  |
+------------+-----------+---------+
| Bob        | McCornick | 3979870 |
+------------+-----------+---------+

Example with Themes.CliTable

┌────────────┬───────────┬─────────┐
│ FIRST NAME │ LAST NAME │   SSN   │
├────────────┼───────────┼─────────┤
│ John       │ Barry     │ 123456  │
│ Kathy      │ Smith     │ 687987  │
│ Bob        │ McCornick │ 3979870 │
└────────────┴───────────┴─────────┘

Example with Themes.CliTableDouble

╔════════════╤═══════════╤═════════╗
║ FIRST NAME │ LAST NAME │   SSN   ║
╟────────────┼───────────┼─────────╢
║ John       │ Barry     │ 123456  ║
║ Kathy      │ Smith     │ 687987  ║
║ Bob        │ McCornick │ 3979870 ║
╚════════════╧═══════════╧═════════╝

Example with table.SetSeparators(Themes.CliTable)and table.SetBorder(false):

  FIRST NAME │ LAST NAME │   SSN    
─────────────┼───────────┼──────────
  John       │ Barry     │ 123456   
  Kathy      │ Smith     │ 687987   
  Bob        │ McCornick │ 3979870  

This change is inspired by node.js's https://github.com/Automattic/cli-table which allows to configure individual characters.

By default it still render as before and still has the same 3 methods for customizing the characters.

I am introducing a new method called `SetSeparators()` which receives an struct with all separators characters.

I am also exposing Themes.Default, Themes.CliTable, Themes.CliTableDouble.
@mattn
Copy link
Collaborator

mattn commented Apr 9, 2019

Looks nice. Could you please rebase master?

@olekukonko
Copy link
Owner

ping @jfromaniello

@olekukonko
Copy link
Owner

A lot of modification has happened since this PR, @mattn should this be closed?

@mfridman
Copy link

This is such an awesome PR, would love to see this land. The CLI theme looks much cleaner.

Example:

+--------+---------+--------------------------------------------------+--------+------+------+------+
│ STATUS │ ELAPSED │                     PACKAGE                      │ COVER  │ PASS │ FAIL │ SKIP │
+--------+---------+--------------------------------------------------+--------+------+------+------+
│ PASS   │ 0.03s   │ github.com/mfridman/rover/pkg/paging/stringpager │ 100.0% │    3 │    0 │    0 │
│ PASS   │ 0.05s   │ github.com/mfridman/rover/tests                  │ 0.0%   │    5 │    0 │    0 │
│ PASS   │ 0.03s   │ github.com/mfridman/rover/tests/helper           │ 0.0%   │    1 │    0 │    0 │
+--------+---------+--------------------------------------------------+--------+------+------+------+

vs

┌────────┬─────────┬──────────────────────────────────────────────────┬────────┬──────┬──────┬──────┐
│ STATUS │ ELAPSED │                     PACKAGE                      │ COVER  │ PASS │ FAIL │ SKIP │
├────────┼─────────┼──────────────────────────────────────────────────┼────────┼──────┼──────┼──────┤
│ PASS   │ 0.03s   │ github.com/mfridman/rover/pkg/paging/stringpager │ 100.0% │    3 │    0 │    0 │
│ PASS   │ 0.05s   │ github.com/mfridman/rover/tests                  │ 0.0%   │    5 │    0 │    0 │
│ PASS   │ 0.03s   │ github.com/mfridman/rover/tests/helper           │ 0.0%   │    1 │    0 │    0 │
└────────┴─────────┴──────────────────────────────────────────────────┴────────┴──────┴──────┴──────┘

@jfromaniello
Copy link
Author

Wow. I do not remember anything about this PR. I haven’t written code in golang for a while. I might have just copied a lot of code from the cli-table project as I mentioned in the request.

I am honestly not sure if I could be of any help.

@mfridman
Copy link

Thanks for putting this together all those years ago. Not sure how actively maintained this package is now, but if time permits I could offer to pick this up.

There is definitely value in allowing this to make the final tables look sharper.

gagern added a commit to gagern/tablewriter that referenced this pull request Apr 26, 2023
This is a follow-up to olekukonko#207
and caters for one of the motivating examples of
olekukonko#115, namely the example with
double outer boundary but single inner lines.

This change does *not* allow all the customization options of that latter
pull request at this stage, but instead reserves the actual representation
of the style as an implementation detail which can evolve as needed, while
only exposing few selected combinations to the caller.
gagern added a commit to gagern/tablewriter that referenced this pull request Apr 26, 2023
This is a follow-up to olekukonko#207
and caters for one of the motivating examples of
olekukonko#115, namely the example with
double outer boundary but single inner lines.

This change does *not* allow all the customization options of that latter
pull request at this stage, but instead reserves the actual representation
of the style as an implementation detail which can evolve as needed, while
only exposing few selected combinations to the caller.
gagern added a commit to gagern/tablewriter that referenced this pull request Apr 26, 2023
This is a follow-up to olekukonko#207
and caters for one of the motivating examples of
olekukonko#115, namely the example with
double outer boundary but single inner lines.

This change does *not* allow all the customization options of that latter
pull request at this stage, but instead reserves the actual representation
of the style as an implementation detail which can evolve as needed, while
only exposing few selected combinations to the caller.
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

Successfully merging this pull request may close these issues.

4 participants