-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathcreate.js
56 lines (48 loc) · 1.45 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
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
const utils = require('../../util');
class FoldersCreateCommand extends BoxCommand {
async run() {
const { flags, args } = await 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>', parse: utils.unescapeSlashes }),
'id-only': Flags.boolean({
description: 'Return only an ID to output from this command'
})
};
FoldersCreateCommand.args = {
parentID: Args.string({
name: 'parentID',
required: true,
hidden: false,
description: 'ID of parent folder to add new folder to, use \'0\' for the root folder'
}),
name: Args.string({
name: 'name',
required: true,
hidden: false,
description: 'Name of new folder'
})
};
module.exports = FoldersCreateCommand;