Skip to content

Refactor file output to use click.File and deduplicate writer logic #1165

@shifa-khan

Description

@shifa-khan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions