forked from VictorTaelin/agda-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathagda-cli.js
executable file
·49 lines (42 loc) · 1009 Bytes
/
agda-cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
const path = require("path");
const {
agdaCheck,
agdaRun,
prettyPrintOutput,
runIO,
} = require("./cli/agda-commands");
const {
parseRunOutput
} = require("./cli/parser");
const command = process.argv[2];
const filePath = process.argv[3];
let ioBackend = process.argv[4];
async function main() {
if (!filePath || !filePath.endsWith(".agda")) {
console.error("Usage: agda-cli [check|run|runIO] <file.agda>");
process.exit(1);
}
switch (command) {
case "check": {
const output = await agdaCheck(filePath);
prettyPrintOutput(output, filePath);
break;
}
case "run": {
const output = await agdaRun(filePath);
const result = parseRunOutput(output);
console.log(result);
break;
}
case "runIO": {
runIO(ioBackend, filePath);
break;
}
default: {
console.error("Invalid command. Use 'check' or 'run' or 'runIO'.");
process.exit(1);
}
}
}
(async () => await main())();