Files
ai-bayarea/run_parser.ts
2026-07-11 15:56:14 -05:00

28 lines
843 B
TypeScript

// run_parser.ts
import { DeterministicParser } from './BuyerSheetParser.ts';
async function main() {
// Einfaches Auslesen der Kommandozeilenargumente
const args = process.argv.slice(2);
const pdfArgIndex = args.indexOf('--pdf');
if (pdfArgIndex === -1 || !args[pdfArgIndex + 1]) {
console.error("Usage: npx ts-node run_parser.ts --pdf <path_to_pdf>");
process.exit(1);
}
const pdfPath = args[pdfArgIndex + 1];
const parser = new DeterministicParser();
try {
console.log(`Lese PDF: ${pdfPath} ...\n`);
const result = await parser.parsePdf(pdfPath);
// JSON formatiert und farbig (optional) ausgeben
console.log(JSON.stringify(result, null, 2));
} catch (error) {
console.error("Fehler beim Parsen des PDFs:", error);
}
}
main();