-
Notifications
You must be signed in to change notification settings - Fork 8
API changes #27
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
API changes #27
Conversation
Removes ability to fit into columns. All cells must be given up front. The `Display` type is removed.
7fee259 to
bf3313a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
In uutils, we always fall back on printing everything in a single column if the width is too small, so we simply use that as the default.
0600f4e to
b9e4252
Compare
|
Those codecov warnings make it really frustrating to look at diffs lol Thanks for working with us on this. I'm testing this out now 👍 |
PThorpe92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
Thanks for testing! I'll quickly mention that I want to do another iteration at some point that's gonna make this more zero-copy as well, but I'm still thinking about how to do that cleanly. |
|
Oops should have requested review instead of assigning :) |
cakebaker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work :)
|
I'm exploring some more improvements right now. Specifically, if we implement a proper width calculation, we don't need
Both are already part of the coreutils dependency tree. I'm tempted to use |
| // https://doc.rust-lang.org/std/primitive.usize.html#method.div_ceil | ||
| /// Division with upward rouding | ||
| // Can be removed on MSRV 1.70. | ||
| /// Division with upward rounding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Division with upward rounding | |
| // Division with upward rounding |
for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea there was that the first few comments are internal, while the last one is the docstring. But it's not a public function, so I can make it consistent if you want.
sylvestre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits, feel free to ignore them
b5811de to
87ccb2f
Compare
|
Ok, @PThorpe92 I need you again :) I've made the pretty drastic change to remove |
|
(I have to update the docs to reflect this still) |
87ccb2f to
fe0a129
Compare
|
I've made even more changes and I think this would be enough for a new release. It passes both the uutils1 and eza2 test suites (huge thanks to @PThorpe92 for testing it!). But of course, these new changes still need to be reviewed. Footnotes |
|
|
||
| let col_width = self.dimensions.widths[x]; | ||
| let padding_size = col_width - cell.width; | ||
| let padding_size = col_width - width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can lead to a panic with "attempt to subtract with overflow". For example, if you set width: 15 in the basic example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed now! I set the width for the fallback to a single column incorrectly. Nice find! Btw, how did find this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right? damn I was gonna say... good catch lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tertsdiepraam I played a bit with the basic example and wanted to see what happens if the width is low/zero ;-)
|
I still need to fix some of those suggestions. I'll get to that soon. I agree with all of them :) |
cakebaker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the exception of the tiny detail in examples/basic.rs it looks good :)
dc71445 to
3faf4d6
Compare
|
Hye, @tertsdiepraam ! With this pull request, does it mean issue #24 should be closed, and others can work with issue #5396? |
|
@allaboutevemirolive If I recall correctly, that PR wasn't quite correct yet right? The functionality that we want with the tabs has not been implemented here yet, so if you still want to work on it, you can. Although, with all the refactoring that happened it might be easier to start over. Sorry for all those changes :) |

Closes #25
Closes #26
Ultimately, I want to refine the API even more, but I think this is a pretty good step in the right direction. Note how all the tests and examples are now more declarative. The
gridvalues never have to bemutableanymore.There is a bit of an ugly thing, which is that
dimensionsis set to some unused dummy value before it is modified. We could refactor this internally with someTempGridor something, but I wanted to focus this PR on the API.Note that (as mentioned in #26) this PR removes the ability to use
fit_into_columns.cc @PThorpe92
The corresponding change in uutils
lswould look like this: https://github.com/uutils/coreutils/pull/5485/files