simplesurance / baur

An incremental task runner for mono repositories.
GNU General Public License v2.0
360 stars 11 forks source link

formatter: align json implementation #520

Closed fho closed 8 months ago

fho commented 8 months ago
formatter: change table and csv implementation to replace nil with ""

Change the table and csv formatters to represent nil as an empty string.
This will allow to pass a nil value to all WriteRow implementations.
The JSON formatter outputs nil values, the others don't.

-------------------------------------------------------------------------------
formatter: align json implementation

Provide a JSON formatter that implements the same Formatter interface as the
other implentations.
The JSON formatter, accepts during intialization a list of field names.
When WriteRows() is called, it accepts the value to be in the field names
order. For every row it creates a Field-Name:Value map and appends it to an
internal slice.
The slice is marshalled and written to an io.Writer when Flush() is called.

This allows to converge the code for using the JSON formatter with the other
output formats.

The "AppName" field in the JSON output of "ls apps" is also changed to "Name".