()
| 161 | |
| 162 | |
| 163 | def main() -> None: |
| 164 | parser = argparse.ArgumentParser( |
| 165 | description="Post-process Go pipeline manpage output: " |
| 166 | "copy sections, rename directories, fix symlinks.", |
| 167 | ) |
| 168 | parser.add_argument( |
| 169 | "src", |
| 170 | help="Source directory (Go pipeline output, e.g. output/manpages.gz/26.04)", |
| 171 | ) |
| 172 | parser.add_argument( |
| 173 | "dst", |
| 174 | help="Destination directory (e.g. manpages/ubuntu/26.04)", |
| 175 | ) |
| 176 | parser.add_argument( |
| 177 | "--log", |
| 178 | default="INFO", |
| 179 | help="Log level (default: INFO)", |
| 180 | ) |
| 181 | parser.add_argument( |
| 182 | "--dry-run", |
| 183 | action="store_true", |
| 184 | help="Show what would be done without writing anything", |
| 185 | ) |
| 186 | args = parser.parse_args() |
| 187 | |
| 188 | logging.basicConfig(level=getattr(logging, args.log.upper(), logging.INFO)) |
| 189 | |
| 190 | src_dir = Path(args.src) |
| 191 | dst_dir = Path(args.dst) |
| 192 | |
| 193 | if not src_dir.is_dir(): |
| 194 | parser.error(f"source directory does not exist: {src_dir}") |
| 195 | |
| 196 | stats = postprocess(src_dir, dst_dir, dry_run=args.dry_run) |
| 197 | |
| 198 | prefix = "(dry run) " if args.dry_run else "" |
| 199 | logger.info( |
| 200 | "%sDone: %d files copied, %d symlinks copied, %d symlinks rewritten, " |
| 201 | "%d symlinks skipped (broken), %d directories skipped", |
| 202 | prefix, |
| 203 | stats.files_copied, |
| 204 | stats.symlinks_copied, |
| 205 | stats.symlinks_rewritten, |
| 206 | stats.symlinks_skipped, |
| 207 | stats.dirs_skipped, |
| 208 | ) |
| 209 | |
| 210 | |
| 211 | if __name__ == "__main__": |
no test coverage detected