-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
executable file
·67 lines (61 loc) · 2.1 KB
/
index.ts
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
#!/usr/bin/env ts-node
import { addChapter } from "./src/add-chapter";
import { outputEbook } from "./src/output-ebook";
import { chapterList } from "./src/chapter-list";
import { crawl } from "./src/crawl";
import "./types";
const { Command } = require("commander");
const program = new Command();
program.description(
"Convert multiple webpages into a single e-book with multiple chapters"
);
program.name("w2eb");
program.usage("add-chapter <url>");
program
.command("add-chapter")
.argument("<url>", "url of the first page of the chapter.")
.option(
"-n, --next <nextSelector>",
"selector for a link to the next page."
)
.option("-c, --content <contentSelector>", "selector of the text content.")
.option(
"-i, --ignore <ignoreSelector>",
"selector of elements that should be ignored from the content."
)
.option("-t, --title <title>", "selector for chapter title.")
.option("-a, --author <author>", "selector for author name.")
.description("Add a new chapter via URL")
.action(addChapter);
program
.command("crawl")
.description(
`collects the HTML contents by requesting the chapter URLs.`
)
.action(crawl);
program
.command("export")
.option("-t, --title <bookTitle>", "Title of the book.")
.description("exports collected data as an e-book")
.action(outputEbook);
program
.command("chapter-list")
.argument("<url>", "URL of the chapter list.")
.option(
"-l, --link <linkSelector>",
"selector for the individual links to the chapters"
)
.option(
"-n, --next <nextSelector>",
"selector for a link to the next page."
)
.option("-c, --content <contentSelector>", "selector of the text content.")
.option(
"-i, --ignore <ignoreSelector>",
"selector of elements that should be ignored from the content."
)
.option("-t, --title <title>", "selector for chapter title.")
.option("-a, --author <author>", "selector for author name.")
.description("adds a list of chapters via URL")
.action(chapterList);
program.parse();