/
cli.js
executable file
·75 lines (60 loc) · 2.4 KB
/
cli.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env node
/* eslint-disable camelcase */
const program = require("commander");
const logSymbols = require("log-symbols");
require("colors");
const pjson = require("./package.json");
const puppeteer_env = require('./lib/cli/puppeteer-env');
const puppeteer_run = require('./lib/cli/puppeteer-run');
const puppeteer_cron = require('./lib/cli/puppeteer-cron');
const puppeteer_bth = require('./lib/cli/puppeteer-bth');
/* --------------------------Commands ------------------------- */
program
.version(pjson.version, "-v --version")
.description(pjson.description.yellow.bold);
program
.command("env")
.description("Load environment variables in .env file(fb_id, fb_pass, email, ..)".blue)
.action(puppeteer_env);
program
.command("run")
.description("Run the automated Birthday wish script".blue)
.option('-w, --watch', 'Show in a browser')
.action(puppeteer_run);
program
.command("cron")
.description("Add a cronjob delete a cronjob, view all cronjobs".blue)
.action(puppeteer_cron);
program
.command("bth")
.option('-w, --watch', 'Show in a browser')
.description("Show all the birthdays for the current day".blue)
.action(puppeteer_bth);
program
.command("*")
.description("When no matching commands are entered".blue)
.action(() => {
console.log(logSymbols.warning, " Command not available".red);
console.log("Type --help to see all the available commands".blue);
});
program.parse(process.argv);
// when no arguments are specified
const NO_COMMAND_SPECIFIED = program.args.length === 0;
if (NO_COMMAND_SPECIFIED) {
console.log("---------------------------------------------------------".yellow.bold);
console.log(`\n PUPPETEER SALVATOR\n`.green.bold);
console.log("---------------------------------------------------------".yellow.bold);
program.outputHelp();
console.log();
console.log('Commands with options:');
console.log(' env'.blue.bold);
console.log(' -h --help \t Show help for this command'.green);
console.log(' cron'.blue.bold);
console.log(' -h --help \t Show help for this command'.green);
console.log(' run'.blue.bold);
console.log(' -h --help \t Show help for this command'.green);
console.log(' -w --watch \t Show in a browser'.green);
console.log(' bth'.blue.bold);
console.log(' -h --help \t Show help for this command'.green);
console.log(' -w --watch \t Show in a browser'.green);
}