forked from Laboratoria/CDMX009-MdLinks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
36 lines (31 loc) · 969 Bytes
/
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
let colors = require("colors");
const { readFile, readFileValidation, readFilesStats } = require("./index.js");
const options = {
path: {
demand: true,
alias: "p",
default: "README.md",
},
};
const argv = require("yargs")
.command("validate", " result of links validation in a Markdow file", options)
.command("stats", " stats of all", options)
.command("validateStats", "Flag indicating if links are validated", options)
.help().argv;
const command = argv._[0];
switch (command) {
case "validate":
console.log(colors.cyan.bold("Validation of the links:"));
readFileValidation(argv.path);
break;
case "stats":
console.log(colors.cyan.bold("Stats of the links:"));
readFilesStats(argv.path);
break;
case "validateStats":
console.log(colors.cyan.bold("Validation and stats of the links:"));
readFile(argv.path);
return;
default:
console.log("Execute de --help command for more information");
}