Closed sebkur closed 5 years ago
Wow cool, very well done! Ignore the build error. Do you think it would be a good idea to change the name of the function from align
to alignColumn
so that later we could add an alignCell
function for alignment of a single cell? I think that'd be a nice addition.
Thanks for the contribution!
Yes, I think renaming to alignColumn
makes sense. I'll update the PR
I pushed a new version a few days ago in case you didn't notice (not sure if you receive a notification about new pushes to my branch)
My apologies, I got caught up in work. It looks good!
Would you make a new release or do you want to wait for more features?
Deployed as version 1.4.0, thanks for reminding me!
Thank you
I added method
public ASCIITable align(int column, Align align)
that allows us to set the alignment of a column (by index) toAlign.RIGHT
. I also added a corresponding test.This is the test example, with column 2 set to
Align.RIGHT
.Note that I took care not to right-align the header. It's a personal preference, I think it looks better if it is not aligned to the right. Added the disambiguating boolean argument
isHeader
toappendRow()
in order to do that. We could make that configurable, too.Some notes
Align.CENTER
will be a bit more tricky. We either to deal with odd number of padding characters where we cannot pad with the same amount of whitespace on each side of the cell's content.align(String columnName, Align align)
with column names as argument. Could also be tricky because we can't really assume column names are unique.