-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathupdate.js
57 lines (49 loc) · 1.34 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
56
57
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
const utils = require('../../util');
class WebLinksUpdateCommand extends BoxCommand {
async run() {
const { flags, args } = await 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',
parse: utils.unescapeSlashes
}),
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 = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the web link to update',
}),
};
module.exports = WebLinksUpdateCommand;