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

Consider deprecating in favour of "table" package #79

Closed
gajus opened this issue Sep 14, 2015 · 20 comments
Closed

Consider deprecating in favour of "table" package #79

gajus opened this issue Sep 14, 2015 · 20 comments

Comments

@gajus
Copy link

gajus commented Sep 14, 2015

I have written a library for displaying data in a table.

https://github.com/gajus/table

This package implements all features of cli-table and addresses some of the open issues:

Consider deprecating cli-table in favour of table package.

The reason I choose to write a library from the ground up is because I am building something that will heavily rely on text tables and neither of the implementations (ascii-table, cli-table or text-table) met my requirements. I have looked at all the source codes. ascii-table package had the best API, but I did not feel comfortable working with a codebase using prototype inheritance, no separation of logic and minimal test coverage.

I have put a lot of thinking into how to make table package modular, easy to test, easy to contribute to and easy to extend for different use cases.

@stevenvachon
Copy link
Contributor

Cool. Does it also have truncation like cli-table?

@gajus
Copy link
Author

gajus commented Sep 15, 2015

@stephanethomas I cannot find the definition of "truncation" in the docs beyond brief statement in the "features" section ("Text truncation based on predefined widths").

If thats a generic truncation of a string in a column, then that falls outside of the "table" formation scope. I suggest you to use a utility function to format data before using it to draw a table, e.g. _.trunc in combination with _.map

That said, table library supports smart content wrapping (column maxWidth property).

@stevenvachon
Copy link
Contributor

truncation with ellipsis: "this is a long sentence" would become "this is a…"

@gajus
Copy link
Author

gajus commented Sep 15, 2015

Do you it is the responsibility of the table formation library to truncate the data?

@stevenvachon
Copy link
Contributor

Not necessarily, but it is convenient and would have familiarity with cli-table.

@jamestalmage
Copy link

http://github.com/jamestalmage/cli-table2 does truncation.

Also has colspan and rowspan, layouts can be as complex as you want.

@gajus
Copy link
Author

gajus commented Sep 15, 2015

@jamestalmage cli-table2 is quite nice. If I had known about it, I'd probably skipped developing table altogether.

I am thinking I pushed table logic a notch too far. Having static column widths (as in cli-table and cli-table2) makes the code logic considerably less complicated. Supporting colspan and rowspan using dynamic widths wouldn't be easy.

@jamestalmage
Copy link

@gajus Thank you!

Sorry I haven't promoted it better 😞

I do make an attempt to support dynamic widths, but it is limited. There is no way to set which column takes priority if there is contention for screen width, nor a way to set a minimum for a dynamic row.

@stevenvachon
Copy link
Contributor

cli-table2 needs to be cleaned up, though ;) you had said it yourself, @jameskoster

@gajus
Copy link
Author

gajus commented Sep 15, 2015

@stevenvachon Please create an issue on https://github.com/gajus/table regarding the ability to truncate content. I will update README.md to reflect the requirement.

@jamestalmage
Copy link

@stevenvachon
There are improvements I want to make, and I mentioned a few issues that prevent completely deprecating this implementation for mine. I have never said "it needs to be cleaned up", or that it was not production ready. It has 100% test coverage, and fixes issues that have gone without resolution here for years. Most importantly, users who post to issues to cli-table2 have seen drastically faster response.

Here is the complete list of open cli-table issues which cli-table2 resolves:

@stevenvachon
Copy link
Contributor

All I know regarding code cleanliness is that #51 (comment) contains

you'd be taking on maintaining a lot of my fugly code. Heaven help you ;)

@gajus
Copy link
Author

gajus commented Oct 4, 2015

V3 released:

  • Added text truncation as requested by @stevenvachon.
  • Added documentation about text wrapping.
  • Removed minWidth, maxWidth properties in favour of a single property width.
  • Added style for borderless table.
  • Added drawJoin callback that controls whether a specific joining/separating row is drawn.
  • Added columnDefault configuration property that sets default column properties that can be overwritten for each individual column.

@gajus
Copy link
Author

gajus commented Oct 8, 2015

Implemented streaming.

https://github.com/gajus/table#table-usage-streaming

@stevenvachon
Copy link
Contributor

Wow, that streaming gif is enticing.

@gajus
Copy link
Author

gajus commented Oct 19, 2015

Implemented word wrapping, e.g.

Without wrapWord:

╔══════════════════════╗
║ Lorem ipsum dolor si ║
║ t amet, consectetur  ║
║ adipiscing elit. Pha ║
║ sellus pulvinar nibh ║
║ sed mauris convallis ║
║ dapibus. Nunc venena ║
║ tis tempus nulla sit ║
║ amet viverra.        ║
╚══════════════════════╝

with wrapWord:

╔══════════════════════╗
║ Lorem ipsum dolor    ║
║ sit amet,            ║
║ consectetur          ║
║ adipiscing elit.     ║
║ Phasellus pulvinar   ║
║ nibh sed mauris      ║
║ convallis dapibus.   ║
║ Nunc venenatis       ║
║ tempus nulla sit     ║
║ amet viverra.        ║
╚══════════════════════╝

@stevenvachon
Copy link
Contributor

Hyphenated? :) awesome work

@ORESoftware
Copy link

Does it have multi-line rows? Looking for that feature in an ascii/unicode table now...

@tecfu
Copy link

tecfu commented May 31, 2016

@ORESoftware

tty-table handles multi-line rows out of the box. It also has a drop-in adapter automattic/cli-table.

var Table = require('tty-table/automattic-cli-table');

...

tty table

@gajus
Copy link
Author

gajus commented Jun 1, 2016

How exactly is this better than "table" package?

On Jun 1, 2016, at 00:44, 5fec8fdadc460cb8540a901f08ef288b [email protected] wrote:

@ORESoftware

tty-table handles multi-line rows out of the box. It also has a drop-in adapter automattic/cli-table.

var Table = require('tty-table/automattic-cli-table');

...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

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

6 participants