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

align columns #3

Open
jcubic opened this issue Aug 24, 2018 · 2 comments
Open

align columns #3

jcubic opened this issue Aug 24, 2018 · 2 comments

Comments

@jcubic
Copy link

jcubic commented Aug 24, 2018

I've tested first example and it give this output:

PID TTY TIME CMD
60881 ttys000 0:00.19 -bash
61674 ttys000 0:00.17 vim README.md

I think it would be more usefull if the output would be

PID   TTY     TIME    CMD
60881 ttys000 0:00.19 -bash
61674 ttys000 0:00.17 vim README.md

it should count the length of each cell and head and pad right to the longest using spaces.

@davepacheco
Copy link
Contributor

Thanks. I'm assuming you saw this:
https://github.com/joyent/node-tab#controlling-field-width-and-alignment

Early feedback was that it was useful to be able to use cut and similar tools with specific column widths, so we opted with that approach for many of the tools that use this library. We could add an 'auto' column width to do what you suggest. That would have the downside that it couldn't be streaming: it would need to see all of the output rows before emitting even the header. That might be appropriate for some situations.

In terms of workaround: as a user, you can get similar behavior using column -t (though it is not quite the same, since column doesn't know which cells are supposed to have whitespace in them).

@jcubic
Copy link
Author

jcubic commented Aug 25, 2018

{width: 'auto'} would be great for use case when user want to display nice looking table. I was thinking on using this in browser (it will be challenging because you don't have stdout), and don't care about streaming, because you display whole table at once.

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