-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathupdate.js
55 lines (47 loc) · 1.24 KB
/
update.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
'use strict';
const BoxCommand = require('../../box-command');
const { flags } = require('@oclif/command');
class WebLinksUpdateCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(WebLinksUpdateCommand);
let updates = {};
if (flags.description) {
updates.description = flags.description;
}
if (flags.name) {
updates.name = flags.name;
}
if (flags.url) {
updates.url = flags.url;
}
let weblink = await this.client.weblinks.update(args.id, updates);
await this.output(weblink);
}
}
WebLinksUpdateCommand.description = 'Update a web link';
WebLinksUpdateCommand.examples = ['box web-links:update 12345 --name "Example Site"'];
WebLinksUpdateCommand._endpoint = 'put_web_links_id';
WebLinksUpdateCommand.flags = {
...BoxCommand.flags,
description: flags.string({
char: 'd',
description: 'Description of the web link'
}),
name: flags.string({
char: 'n',
description: 'Name of the web link'
}),
url: flags.string({
char: 'u',
description: 'The URL the web link points to. Must start with "http://" or "https://"'
})
};
WebLinksUpdateCommand.args = [
{
name: 'id',
required: true,
hidden: false,
description: 'ID of the web link to update',
}
];
module.exports = WebLinksUpdateCommand;