-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathcreate.js
54 lines (46 loc) · 1.38 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
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
const utils = require('../../util');
class WebLinksCreateCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(WebLinksCreateCommand);
let options = {};
if (flags.description) {
options.description = flags.description;
}
if (flags.name) {
options.name = flags.name;
}
let weblink = await this.client.weblinks.create(args.url, flags['parent-id'], options);
await this.output(weblink);
}
}
WebLinksCreateCommand.description = 'Create a new web link';
WebLinksCreateCommand.examples = ['box web-links:create http://example.com --parent-id 0'];
WebLinksCreateCommand._endpoint = 'post_web_links';
WebLinksCreateCommand.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. Defaults to the URL if not set'
}),
'parent-id': Flags.string({
required: true,
description: 'ID of the folder to create the web link in',
}),
};
WebLinksCreateCommand.args = {
url: Args.string({
name: 'url',
required: true,
hidden: false,
description: 'The URL the web link points to. Must start with "http://" or "https://"',
}),
};
module.exports = WebLinksCreateCommand;