-
Notifications
You must be signed in to change notification settings - Fork 7
/
create.js
56 lines (46 loc) · 1.54 KB
/
create.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
const { TwilioClientCommand } = require("@twilio/cli-core").baseCommands,
AutopilotCore = require("@dabblelab/autopilot-core"),
ora = require("ora"),
{
convertYargsOptionsToOclifFlags,
normalizeFlags,
} = require("../../../utils"),
{ options, describe } = require("../../../lib/options/modelbuilds/create");
class CreateModelBuilds extends TwilioClientCommand {
async run() {
await super.run();
let { flags } = await this.parse(CreateModelBuilds);
flags = normalizeFlags(flags);
if (!flags.hasOwnProperty("assistantSid")) {
console.log(`The '--assistant-sid' is required`);
return;
}
const spinner = ora().start("Creating modelbuilds...\n");
try {
const { assistantSid, callbackURL } = flags;
let modelbuilds = "";
if (callbackURL)
modelbuilds = await AutopilotCore.modelBuilds.create(
this.twilioClient,
assistantSid,
{ statusCallback: callbackURL }
);
else
modelbuilds = await AutopilotCore.modelBuilds.create(
this.twilioClient,
assistantSid
);
spinner.stop();
console.log(`ModelBuild status : ${modelbuilds.status}`);
} catch (err) {
spinner.stop();
console.error(`ERROR: ${err.message}`);
}
}
}
CreateModelBuilds.description = describe;
CreateModelBuilds.flags = Object.assign(
convertYargsOptionsToOclifFlags(options),
{ profile: TwilioClientCommand.flags.profile }
);
module.exports = CreateModelBuilds;