consolidation / output-formatters

Apply transformations to structured data to write output in different formats.
Other
192 stars 13 forks source link

Add FIELDS_CAME_FROM_DEFAULT #102

Closed greg-1-anderson closed 1 year ago

greg-1-anderson commented 1 year ago

Overview

This pull request:

Summary

Give clients the ability to declare that the FIELDS field came from default values, not from user-supplied values, by setting FIELDS_CAME_FROM_DEFAULT.

Description

When we declare the Symfony Console Input description for the --fields option, we give it the default values so that they may be rendered in the help output. However, doing this means that the FormatterOptions::FIELDS field is set with the result of fetching the value of this Input object, and there currently is no way to tell if the value returned came from the user or the defaults. This subverts our feature where we can provide different default fields for human-readable output formats.

To fix this, we provide a new field, FIELDS_CAME_FROM_DEFAULT, which clients may call e.g. if $args->hasOption('fields') returns false.

greg-1-anderson commented 1 year ago

This doesn't seem to be necessary; the default-table-fields field is working correctly in most instances.