-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (46 loc) · 1.38 KB
/
index.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
require("dotenv").config();
const process = require("process");
const yargs = require("yargs");
const change = require("./src/twilio-url");
const list = require("./src/twilio-sid");
async function main() {
const argv = yargs
.command("url", "Which URL should be defined in twilio", {
url: {
description: "the url to set",
alias: "u",
type: "string",
},
})
.command("sid", "List of Twilio SID numbers", {
phone: {
description: "the SID list",
alias: "s",
type: "string",
},
})
.option("psid", {
alias: "p",
description: "Tell the SID of Phone Number",
type: "string",
})
.help()
.alias("help", "h").argv;
const accountSid = process.env.accountSid;
const authToken = process.env.authToken;
try {
if (argv._.includes("sid")) {
console.log("Listing SIDs ... ");
list.twilio(accountSid, authToken);
}
if (argv._.includes("url")) {
const [, url] = argv._;
const { p: sid } = argv;
console.log("Changing Twilio URL ... ", url);
change.twilio(accountSid, authToken, sid, url);
}
} catch (e) {
console.log("[ERROR]", e);
}
}
main();