#!/usr/bin/env node
const fs = require('fs');
const parser = require('@babel/parser');

const filePath = process.argv[2];

if (!filePath) {
    console.error("Please provide a file path.");
    process.exit(1);
}

try {
    const code = fs.readFileSync(filePath, 'utf8');
    const ast = parser.parse(code, {
        sourceType: "module",
        plugins: [
            "jsx",
            "typescript"
        ]
    });

    console.log(JSON.stringify(ast, null, 2));

} catch (error) {
    console.error(`Failed to parse ${filePath}:`, error.message);
    process.exit(1);
}
