Refactor: Update CLI to use ES Module import

This commit is contained in:
2025-09-26 00:53:41 -07:00
parent df70da0c04
commit 675923b5f8

27
cli.js Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env node
import { readFileSync } from 'fs';
import { resolve } from 'path';
import { hi2js } from './transpiler.js';
function main() {
const args = process.argv.slice(2);
if (args.length !== 1) {
console.error("Master, please provide a single file path.");
console.error("Usage: node cli.js <file.hi>");
process.exit(1);
}
const hiFilePath = resolve(args[0]);
try {
const hiCode = readFileSync(hiFilePath, 'utf-8');
const jsCode = hi2js(hiCode);
console.log(jsCode);
} catch (error) {
console.error(`Error processing file: ${error.message}`);
process.exit(1);
}
}
main();