df: fix incorrect whitespace between columns#3386
Conversation
c0ed20a to
73e472b
Compare
|
Super cool! It'd be interesting to find similar cases in other utils and put this functionality in uucore (after this PR of course). There are plenty of utils that have some table-like format ( |
There was a problem hiding this comment.
This is certainly an improvement but it doesn't quite match the behavior of GNU. The last column in the table does not have trailing spaces.
This is certainly an improvement so I'm okay with merging this as-is, but just bringing it up as another opportunity to improve the output of df.
There was a problem hiding this comment.
Hm, I think you misread the snippet above. It contains a single column with a header and three values. And the trailing spaces are there because those values are shorter than the header.
There was a problem hiding this comment.
Yes, I understand. When I said "the last column" I should have said "the last and only column in this test case". What I meant is that in GNU df there are no trailing spaces in the rightmost column of the output table:
$ touch a && df --output=file a | tr " " "_"
File
a
But in this branch there are trailing spaces:
$ touch a && ./target/debug/df --output=file a | tr " " "_"
File
a___
I'm okay with it, I just wanted to mention it as a follow-up improvement for a future pull request.
There was a problem hiding this comment.
Thanks for the explanation, that makes sense.
|
Could you please fix the conflict? thanks |
e59f219 to
df78d86
Compare
tertsdiepraam
left a comment
There was a problem hiding this comment.
Two small nits/questions, but looks good!
|
Excellent work! |
The main idea behind this PR is to introduce a
Tablestruct to print a table. The print process now consists of two steps: 1) calculate the widths of the columns and 2) print the data.HeaderandDisplayRow(which has been renamed toRowFormatter(I'm not sure about this name, I struggled to find a name for it)) no longer do any output, they simply prepare the strings used by the table.Fixes #3194.