Several commands duplicate the full writer block across if output / else branches when writing to a file vs stdout. This can be simplified by switching --output from clickext.ClickPath() to click.File("w") and passing io.TextIO to the export functions. This removes the need for manual open()/close() handling and eliminates the duplicated code paths.
Affected commands:
package list-versions - _export_versions_csv, _export_versions_json, _export_versions_table
list-overrides - _export_csv, _export_json
graph - constraints, to-dot
build-order
minimize
Several commands duplicate the full writer block across if output / else branches when writing to a file vs stdout. This can be simplified by switching --output from clickext.ClickPath() to click.File("w") and passing io.TextIO to the export functions. This removes the need for manual open()/close() handling and eliminates the duplicated code paths.
Affected commands:
package list-versions -
_export_versions_csv,_export_versions_json,_export_versions_tablelist-overrides -
_export_csv,_export_jsongraph -
constraints,to-dotbuild-orderminimize