-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
38 lines (34 loc) · 887 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
37
38
#!/usr/bin/env node
const yargs = require("yargs");
const { generateTableOfContent } = require("./lib");
yargs
.scriptName("repo-toc")
.usage("$0 [options]")
.option("dir", {
alias: "d",
describe: "Directory path to generate TOC for",
type: "string",
demandOption: false,
default: process.cwd(),
})
.option("ext", {
alias: "e",
describe: "File extensions to include (comma-separated)",
type: "string",
demandOption: false,
default: ".md",
})
.option("output", {
alias: "o",
describe: "File path to save the TOC",
type: "string",
demandOption: false,
default: "./README.md",
})
.help()
.alias("help", "h").argv;
const options = yargs.argv;
const dirPath = options.dir;
const extensions = options.ext.split(",");
const filePath = options.output;
generateTableOfContent({ dirPath, extensions, filePath });