-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
46 lines (42 loc) · 1.35 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
#!/usr/bin/env node
import scrapper from "./index.js";
import yargs from "yargs";
const { u: classroomUrl, h: headless, r: regularWait, o: otp } = yargs
.option("classroom-url", {
alias: "u",
describe:
"The url from the GitHub Clasroom e.g. https://classroom.github.com/classrooms/your-classroom",
demandOption: "Provide a classroom url that we can fetch for you :)",
type: "string",
nargs: 1,
})
.option("otp", {
alias: "o",
describe:
"This is the one time password that GitHub need in order to login",
demandOption: "We need your one time password for login into GitHub",
type: "string",
nargs: 1,
})
.option("regular-wait", {
alias: "r",
describe:
"The waiting time interval in ms for fetching urls. Increase if you have slow internet connection. Default: 5000",
type: "number",
nargs: 1,
})
.option("headless", {
alias: "h",
describe:
"Add --no-headless if you want to see the actual automated browser working.",
type: "boolean",
nargs: 0,
})
.help().argv;
const { GH_EMAIL: email, GH_PASSWORD: password } = process.env;
if (email && password)
scrapper(classroomUrl, process.env.GH_EMAIL, process.env.GH_PASSWORD, otp, {
regularWait: regularWait,
headless: !headless,
});
else console.log("ENV variables GH_EMAIL and GH_PASSWORD are required");