-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs.js
79 lines (73 loc) · 2.08 KB
/
args.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
76
77
78
79
import { Command } from "commander";
import {
DEFAULT_FETCH_COUNT,
DEFAULT_FILENAME,
MIN_DELAY,
RANDOMIZE_OFFSET_VALUE,
UPLOAD_THRESHOLD,
} from "./constants.js";
const program = new Command();
program
.option("--cursor <value>", "Set the cursor value", "")
.option("--user-id <value>", "Set twitter user id")
.option(
"--fetch-count <value>",
"Set total followers to fetch",
DEFAULT_FETCH_COUNT
)
.option("--all", "fetch all the followers?", false)
.option(
"--upload-count <value>",
"Set upload threshold(Upload to google sheets or save to file after how many are fetched?)",
UPLOAD_THRESHOLD
)
.option(
"--min-delay <value>",
"Set minimum delay before making each request",
MIN_DELAY
)
.option(
"--save-to-sheets",
"Save the output to google sheets? (will override --csv-filename option)",
false
)
.option(
"--csv-filename <value>",
"Set the output filename for the CSV (will be ignored if --save-to-google-sheets option is set to true)",
DEFAULT_FILENAME
)
.option(
"--fields-to-save <value>",
"Fields to save in the CSV. Comma separated list of fields",
"name,username,verified,profile_link,location,followers_count,friends_count,profile_image_url,description,created_at,media_count,statuses_count"
)
.option(
"--random-offset <value>",
"Additional random delay value while fetching followers",
RANDOMIZE_OFFSET_VALUE
)
.parse(process.argv);
const options = program.opts();
const cursor = options.cursor;
const userId = options.userId;
const fetchAll = options.all;
const uploadThreshold = Number(options.uploadCount);
const minDelay = Number(options.minDelay);
const fetchCount = Number(options.fetchCount);
const saveToGoogleSheets = Boolean(options.saveToSheets);
const csvFilename = options.csvFilename;
const fieldsToSave = options.fieldsToSave.split(",");
const randomOffset = options.randomOffset;
const args = {
cursor,
userId,
fetchAll,
uploadThreshold,
minDelay,
fetchCount,
saveToGoogleSheets,
csvFilename,
fieldsToSave,
randomOffset,
};
export { args };