(source, dest, clipboard)
| 75 | help="Read input from clipboard explicitly.", |
| 76 | ) |
| 77 | def main(source, dest, clipboard): |
| 78 | # Determine the source of input |
| 79 | if clipboard or (not source and not sys.stdin.isatty()): |
| 80 | # Read from clipboard |
| 81 | lines = read_from_clipboard() |
| 82 | elif source: |
| 83 | # Read from specified file |
| 84 | lines = read_changes_file(source) |
| 85 | else: |
| 86 | # Default: read from clipboard |
| 87 | lines = read_from_clipboard() |
| 88 | |
| 89 | output_lines = [] |
| 90 | for line in lines: |
| 91 | output_line = process_line(line) |
| 92 | if output_line == "STOP_PROCESSING": |
| 93 | break |
| 94 | if output_line: |
| 95 | output_lines.append(output_line) |
| 96 | |
| 97 | output_text = "\n".join(output_lines) |
| 98 | |
| 99 | # Prepare the header |
| 100 | version = "x.y.z" |
| 101 | underline = "=" * len(version) |
| 102 | |
| 103 | header = f""" |
| 104 | .. _version-{version}: |
| 105 | |
| 106 | {version} |
| 107 | {underline} |
| 108 | |
| 109 | :release-date: <YYYY-MM-DD> |
| 110 | :release-by: <FULL NAME> |
| 111 | |
| 112 | What's Changed |
| 113 | ~~~~~~~~~~~~~~ |
| 114 | """ |
| 115 | |
| 116 | # Combine header and output |
| 117 | final_output = header + output_text |
| 118 | |
| 119 | # Write output to destination |
| 120 | if dest.name == "<stdout>": |
| 121 | print(Fore.GREEN + "Copy the following text to Changelog.rst:") |
| 122 | print(Fore.YELLOW + header) |
| 123 | print(Fore.CYAN + output_text) |
| 124 | else: |
| 125 | dest.write(final_output + "\n") |
| 126 | dest.close() |
| 127 | |
| 128 | |
| 129 | if __name__ == "__main__": |
no test coverage detected