-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcli.ts
38 lines (32 loc) · 843 Bytes
/
cli.ts
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
#!/usr/bin/env node
import fs from "fs";
import path from "path";
import server from "./server";
const args = process.argv.slice(2)
const help = `ReScript Language Server
Usage: rescript-language-server [options]
Options:
--stdio Use stdio
--node-ipc Use node-ipc
-v, --version Print version
-h, --help Print help`;
(() => {
switch (args[0]) {
case '--stdio':
return server(true);
case '--node-ipc':
return server(false);
case '--version':
case '-v':
const { version } = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json")).toString())
console.log(version);
process.exit(0);
case '--help':
case '-h':
console.log(help);
process.exit(0);
default:
console.log(help);
process.exit(1)
}
})();