[it] requires a pretty significant refactor of the printPaddedColumns() function in hacks/helpers/js, mainly to support multiple columns (instead of just two, which it does currently)
... here it is, in all its glory, the refactoring of printPaddedColumns() to support multiple (ie. more than 2) colums.
The printPaddedColumns() function has changed so much that the GitHub diff is probably meaningless, so probably better to just grok the new version.
Thanks to the new implementation, though, I was able to get rid of the now-superfluous mergePaddedValues() function, as that function just made up for the lack of proper multi-column support in printPaddedColumns().
The main benefits of this new version are (1) how it simplifies printing out multiple padded columns, and (2) how it supports a variable number of columns (1 upto ∞, in theory at least :smile:):
BTW: this PR is again a pure refactoring of existing logic, it doesn't change anything functionally, as you can verify by running the show dbs, count collections, show collections, and count documents shell commands... they behave exactly as before, and their output is identical. So much win! :smile:
Hey @TylerBrock,
In https://github.com/TylerBrock/mongo-hacker/pull/148#discussion_r51252848 I wrote:
... here it is, in all its glory, the refactoring of
printPaddedColumns()
to support multiple (ie. more than 2) colums.The
printPaddedColumns()
function has changed so much that the GitHub diff is probably meaningless, so probably better to just grok the new version.Thanks to the new implementation, though, I was able to get rid of the now-superfluous
mergePaddedValues()
function, as that function just made up for the lack of proper multi-column support inprintPaddedColumns()
.The main benefits of this new version are (1) how it simplifies printing out multiple padded columns, and (2) how it supports a variable number of columns (1 upto ∞, in theory at least :smile:):
before
after
... which will enable me to merge this into #148 to implement the "dynamic" padding you wanted to fix first.
Going forward, this function can be used to print and layout even more columns, not just the three that we have at the moment:
BTW: this PR is again a pure refactoring of existing logic, it doesn't change anything functionally, as you can verify by running the
show dbs
,count collections
,show collections
, andcount documents
shell commands... they behave exactly as before, and their output is identical. So much win! :smile: