Print/write the validation report. If report_file is set, writes to that file. Otherwise prints to stdout. If changelog_file is set, also writes the generated CHANGELOG.md to that file. Note: Info messages are printed live during validation, not repeated here.
(self, analysis: Optional[Dict] = None, changelog_preview: Optional[str] = None)
| 1069 | return json.dumps(report_data, indent=2) |
| 1070 | |
| 1071 | def print_report(self, analysis: Optional[Dict] = None, changelog_preview: Optional[str] = None): |
| 1072 | """Print/write the validation report. |
| 1073 | |
| 1074 | If report_file is set, writes to that file. Otherwise prints to stdout. |
| 1075 | If changelog_file is set, also writes the generated CHANGELOG.md to that file. |
| 1076 | |
| 1077 | Note: Info messages are printed live during validation, not repeated here. |
| 1078 | """ |
| 1079 | # Generate report based on format |
| 1080 | if self.report_format == "json": |
| 1081 | report = self._generate_json_report(analysis) |
| 1082 | elif analysis: |
| 1083 | report = self.generate_report(analysis) |
| 1084 | else: |
| 1085 | report = self._generate_error_only_report() |
| 1086 | |
| 1087 | # Output report to file or stdout |
| 1088 | if self.report_file: |
| 1089 | self.report_file.write_text(report) |
| 1090 | # Always print errors to stdout so user is alerted even when writing to file |
| 1091 | if self.errors: |
| 1092 | print("ERRORS:") |
| 1093 | for error in self.errors: |
| 1094 | print(f" ✗ {self._format_error_for_display(error)}") |
| 1095 | if self.warnings: |
| 1096 | print("WARNINGS:") |
| 1097 | for warning in self.warnings: |
| 1098 | print(f" ⚠ {warning}") |
| 1099 | print(f"Report written to: {self.report_file}") |
| 1100 | else: |
| 1101 | print(report) |
| 1102 | |
| 1103 | # Write changelog preview if requested |
| 1104 | if changelog_preview and self.changelog_file: |
| 1105 | self.changelog_file.write_text(changelog_preview) |
| 1106 | print(f"Changelog written to: {self.changelog_file}") |
| 1107 | |
| 1108 | |
| 1109 | def main(): |
no test coverage detected