-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
33 lines (32 loc) · 1.11 KB
/
cli.ts
File metadata and controls
33 lines (32 loc) · 1.11 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
import { rmSync } from 'fs';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import main from './src';
import type { Config } from './src/global/types/config';
import { EntityType, LANG } from './src/global/types/enums';
import init from './src/init/init';
yargs(hideBin(process.argv))
.command('parse <entity> [options..]', 'parse the entity given', () => {}, (argv) => {
const config: Config = {
skipLocal: argv.skipLocal as boolean || false,
entity: EntityType[argv.entity as EntityType],
language: LANG.EN,
exportPath: argv.exportPath as string || './parsed',
exportType: argv.exportType as string || 'local/raw',
};
main(config);
})
.command('init [options..]', 'Initialise dev and local parser environment', () => {}, (argv) => {
init();
})
.command('clean <type>', 'Cleans Up downloaded data or parsed data', () => {}, (argv) => {
if (argv.type === 'parsed') {
rmSync('./parsed', { recursive: true });
}
if (argv.type === 'data') {
rmSync('./data', { recursive: true });
}
})
.demandCommand(1)
.help()
.parse();