-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Adding optional columns to Table #44916
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
Comments
I like the idea, but IMHO the name "optional" is wrong. That sounds more like a "show column if user enables it". What about |
Yeah I'm happy to improve naming. |
I like this idea. For naming, we can reverse the POV and call it |
may I suggest to keep the meaning in the web context - |
For me, |
Thank you for this issue. |
Nope, still would be nice to have. |
Hello @carsonbot and all,
|
|
Let's say we have max-width of 80 characters with col[0] = 20 chars, col[1] = 40 chars and col[2] = 30 chars
If we go with
|
Good question about the truncation.. Could be You may want an array of options per column to have max flexibility/forward capability, so you could add priorities or min length or whatever.. Up to you if you wanna go crazy with this :) I just thought it'd be nice to have basic capability built-in to simplify consumer code. |
Thank you for this issue. |
Nope, still would be nice to have. |
Thank you for this issue. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Yes yes, still would be nice, just needs someone with time and motivation 🤞🏻 |
Uh oh!
There was an error while loading. Please reload this page.
Description
There are cases where you don't want to wrap content because it may be too big and wrapping does make the output much messier and hard to read.
One example is
composer search foo
where we do not care to show the full package description if it is too long. So you get output like this:Where the description was capped at the terminal width.
The way it's achieved is by calculating everything manually as using Table does not let you achieve this:
https://github.com/composer/composer/blob/711f436b2431ebf2845ee89a556ffde619212405/src/Composer/Command/SearchCommand.php#L101-L117
I believe having a concept of optional columns would solve this, whereas Table::calculateColumnsWidth could compute the max width of everything, then reduce the optional columns until everything fits on screen, and if not possible drop these columns entirely.
Example
This would be the above code from Composer rewritten to use the Table if optional columns where supported:
The code is much leaner, doesn't have to deal with all the width calculations, and as a bonus it probably fixes bugs because
calculateColumnsWidth
does width calculation much smarter thanstrlen()
.The text was updated successfully, but these errors were encountered: