dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
679 stars 75 forks source link

Total tracked time #106

Closed retronav closed 3 years ago

retronav commented 3 years ago

This PR closes #58. Notable changes in this pull request are:

PTAL @dominikbraun

dominikbraun commented 3 years ago

Thanks, this looks pretty good for me. I've discovered one thing:

The current output looks like this:

+-----+------------------+-----------+---------+-----------+------------+
|  #  |       KEY        |  PROJECT  |  START  |    END    |  BILLABLE  |
+-----+------------------+-----------+---------+-----------+------------+
|   1 | 2021-06-07-12-53 | web-store | 12:53   | 15:57     | no         |
|   2 | 2021-06-07-07-20 |           | 07:20   | 12:08     | no         |
+-----+------------------+-----------+---------+-----------+------------+
|     |                  |           |         |  TOTAL:   |  7H 51MIN  |
+-----+------------------+-----------+---------+-----------+------------+

It would be possible to make it look like so:

+-----+------------------+-----------+---------+---------+------------+
|  #  |       KEY        |  PROJECT  |  START  |   END   |  BILLABLE  |
+-----+------------------+-----------+---------+---------+------------+
|   1 | 2021-06-07-12-53 | web-store | 12:53   | 15:57   | no         |
|   2 | 2021-06-07-07-20 | web-store | 07:20   | 12:08   | no         |
+-----+------------------+-----------+---------+---------+------------+
|                                                TOTAL:  |  7H 51MIN  |
+-----+------------------+-----------+---------+---------+------------+

If there are two or more empty cells next to each other, tablewriter merges the cells as showed in the 2nd output. You're already passing empty cell values to out.Table, but then headersWithPadding adds to spaces and "" becomes " ".

To fix this, you could either check in headersWithPadding whether the current cell is not empty, or even just remove the paddedFooters := headersWithPadding(footer) assignment.

retronav commented 3 years ago

I have changed headersWithPadding to not pad empty headers. So the output format is now as expected!