-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 873 Bytes
/
index.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
import { program } from "commander";
import { checkAndInsert, seeder } from "./fetcher.js";
import { cronSchedule } from "./cronScheduler.js";
import { Logger } from "./message.js";
program
.option("-i, --init", "Run seeder function")
.option("-v, --verbose", "Enable verbose logging")
.requiredOption(
"-c, --cronjob <value>",
"Set desired cronjob value (e.g. -c 2h, -c 1d, or -c 30m)"
)
.parse(process.argv);
const { init, verbose, cronjob } = program.opts();
const logger = new Logger(verbose);
async function main() {
if (init) {
logger.info("Running the seeder function...");
await seeder();
}
if (cronjob) {
console.log(`[+] Starting the cronjob ${cronjob}`);
cronSchedule(cronjob, checkAndInsert);
} else {
logger.info("Pleaser provide your cronjob in order to run the tool.");
process.exit(1);
}
}
main();