-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathrename.js
51 lines (42 loc) · 1.22 KB
/
rename.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
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
const utils = require('../../util');
class FoldersRenameCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(FoldersRenameCommand);
let updates = {
name: args.name,
};
if (flags.description) {
updates.description = flags.description;
}
if (flags.etag) {
updates.etag = flags.etag;
}
let renamedFolder = await this.client.folders.update(args.id, updates);
await this.output(renamedFolder);
}
}
FoldersRenameCommand.description = 'Rename a folder';
FoldersRenameCommand.examples = ['box folders:rename 22222 "New Folder Name"'];
FoldersRenameCommand.flags = {
...BoxCommand.flags,
description: Flags.string({ description: 'Change the folder description', parse: utils.unescapeSlashes }),
etag: Flags.string({ description: 'Only rename if etag value matches' })
};
FoldersRenameCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the folder to rename',
}),
name: Args.string({
name: 'name',
required: true,
hidden: false,
description: 'New name for the folder',
}),
};
module.exports = FoldersRenameCommand;