-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
32 lines (28 loc) · 832 Bytes
/
index.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
import { Command, Option } from "commander";
import { MakerFactory } from "./factory";
import { DictEnum } from "./config";
const program = new Command();
program
.version("1.0.0")
.name("ts-node")
.usage("index.ts [options]")
.addOption(
new Option("-t, --type <type>", "dictionary type").choices(
Object.values(DictEnum)
)
)
.option(
"-d, --download",
"download the latest json file from SuttaCentral repository"
)
.option("-e, --eudic", "for eudic")
.action((options) => {
if (!Object.values(DictEnum).includes(options.type)) {
console.error("error: invalid options!");
process.exit();
}
const forEudic = options.eudic ?? false;
const maker = MakerFactory.create(options.type);
maker.make(options.download, forEudic);
});
program.parse(process.argv);