-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathcreate.js
55 lines (47 loc) · 1.34 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
'use strict';
const BoxCommand = require('../../box-command');
const { flags } = require('@oclif/command');
class FoldersCreateCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FoldersCreateCommand);
let params = {
body: {
name: args.name,
parent: {
id: args.parentID
}
}
};
if (flags.description) {
params.body.description = flags.description;
}
// @TODO (2018-07-10): Should implement this using the Node SDK
let createdFolder = await this.client.wrapWithDefaultHandler(this.client.post)('/folders', params);
await this.output(createdFolder);
}
}
FoldersCreateCommand.description = 'Create a new folder';
FoldersCreateCommand.examples = ['box folders:create 22222 "New Subfolder"'];
FoldersCreateCommand._endpoint = 'post_folders';
FoldersCreateCommand.flags = {
...BoxCommand.flags,
description: flags.string({ description: 'A description for folder <DESCRIPTION>' }),
'id-only': flags.boolean({
description: 'Return only an ID to output from this command'
})
};
FoldersCreateCommand.args = [
{
name: 'parentID',
required: true,
hidden: false,
description: 'ID of parent folder to add new folder to, use \'0\' for the root folder'
},
{
name: 'name',
required: true,
hidden: false,
description: 'Name of new folder'
}
];
module.exports = FoldersCreateCommand;