-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-parser.js
More file actions
52 lines (44 loc) · 1.37 KB
/
cli-parser.js
File metadata and controls
52 lines (44 loc) · 1.37 KB
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
50
51
52
#!/usr/bin/env jsc
// IPS Crash Report Parser - CLI Version
import { IPSParser } from './ips-parser-core.js';
// CLI Implementation
function main(args) {
// Show usage if no arguments
if (args.length === 0) {
print("Usage: jsc -m cli-parser.js -- <input.ips>");
print("");
print("Convert Apple crash report (.ips) to plain text format.");
print("The -m flag is required to enable ES6 module support.");
print("");
print("Examples:");
print(" jsc -m cli-parser.js -- crash.ips");
print(" jsc -m cli-parser.js -- crash.ips > crash.txt");
quit(1);
}
const inputFile = args[0];
// Read input file
let content;
try {
content = readFile(inputFile);
} catch (error) {
print(`Error: Cannot read file '${inputFile}': ${error.message}`);
quit(1);
}
// Parse and format
let formatted;
try {
const parser = new IPSParser(content);
parser.parse();
formatted = parser.formatReport();
} catch (error) {
print(`Error: ${error.message}`);
quit(1);
}
// Output to stdout
print(formatted);
quit(0);
}
// Run main - pass global arguments (available in jsc after --)
// arguments is only defined if CLI params are passed
const cliArgs = (typeof arguments !== 'undefined') ? arguments : [];
main(cliArgs);