| 54 | } |
| 55 | |
| 56 | function printUsage(): void { |
| 57 | const lines = [ |
| 58 | "make-pdf — turn markdown into publication-quality PDFs", |
| 59 | "", |
| 60 | "Usage:", |
| 61 | ]; |
| 62 | for (const [name, info] of COMMANDS) { |
| 63 | lines.push(` $P ${info.usage}`); |
| 64 | lines.push(` ${info.description}`); |
| 65 | } |
| 66 | lines.push(""); |
| 67 | lines.push("Output format:"); |
| 68 | lines.push(" --to pdf|html|docx What to produce (default: pdf)."); |
| 69 | lines.push(" html = single self-contained file, no network refs."); |
| 70 | lines.push(" docx = content fidelity, diagrams as PNG."); |
| 71 | lines.push(""); |
| 72 | lines.push("Page layout:"); |
| 73 | lines.push(" --margins <dim> All four margins (default: 1in). in, pt, cm, mm."); |
| 74 | lines.push(" --page-size letter|a4|legal (aliases: --format — page SIZE, not output format)"); |
| 75 | lines.push(""); |
| 76 | lines.push("Document structure:"); |
| 77 | lines.push(" --cover Add a cover page."); |
| 78 | lines.push(" --toc Generate clickable table of contents."); |
| 79 | lines.push(" --no-chapter-breaks Don't start a new page at every H1."); |
| 80 | lines.push(""); |
| 81 | lines.push("Branding:"); |
| 82 | lines.push(" --watermark <text> Diagonal watermark on every page."); |
| 83 | lines.push(" --header-template <html>"); |
| 84 | lines.push(" --footer-template <html> Mutex with --page-numbers."); |
| 85 | lines.push(" --no-confidential Suppress the CONFIDENTIAL footer."); |
| 86 | lines.push(""); |
| 87 | lines.push("Output control:"); |
| 88 | lines.push(" --page-numbers / --no-page-numbers (default: on)"); |
| 89 | lines.push(" --tagged / --no-tagged (default: on, accessible PDF)"); |
| 90 | lines.push(" --outline / --no-outline (default: on, PDF bookmarks)"); |
| 91 | lines.push(" --quiet Suppress progress on stderr."); |
| 92 | lines.push(" --verbose Per-stage timings on stderr."); |
| 93 | lines.push(""); |
| 94 | lines.push("Diagrams & images:"); |
| 95 | lines.push(" ```mermaid / ```excalidraw fences render as vector diagrams."); |
| 96 | lines.push(" Add render=false to a fence info string to keep it as a code block."); |
| 97 | lines.push(" Local images are inlined; oversized rasters downscale to print resolution."); |
| 98 | lines.push(" --strict Missing/remote images fail the run (CI mode)."); |
| 99 | lines.push(""); |
| 100 | lines.push("Network:"); |
| 101 | lines.push(" --allow-network Load external images (off by default)."); |
| 102 | lines.push(""); |
| 103 | lines.push("Examples:"); |
| 104 | lines.push(" $P generate letter.md"); |
| 105 | lines.push(" $P generate --cover --toc essay.md essay.pdf"); |
| 106 | lines.push(" $P generate --watermark DRAFT memo.md draft.pdf"); |
| 107 | lines.push(" $P preview letter.md"); |
| 108 | lines.push(""); |
| 109 | lines.push("Run `$P setup` to verify browse + Chromium + pdftotext install."); |
| 110 | console.error(lines.join("\n")); |
| 111 | } |
| 112 | |
| 113 | function generateOptionsFromFlags(parsed: ParsedArgs): GenerateOptions { |