-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathrename.js
51 lines (42 loc) · 1.19 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 FilesRenameCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(FilesRenameCommand);
let options = {
name: args.name,
};
if (flags.hasOwnProperty('description')) {
options.description = flags.description;
}
if (flags.etag) {
options.etag = flags.etag;
}
let file = await this.client.files.update(args.id, options);
await this.output(file);
}
}
FilesRenameCommand.description = 'Rename a file';
FilesRenameCommand.examples = ['box files:rename 11111 "New File Name.pdf"'];
FilesRenameCommand.flags = {
...BoxCommand.flags,
description: Flags.string({ description: 'Change the file description', parse: utils.unescapeSlashes }),
etag: Flags.string({ description: 'Only rename if etag value matches' })
};
FilesRenameCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of file to rename'
}),
name: Args.string({
name: 'name',
required: true,
hidden: false,
description: 'New name of file'
}),
};
module.exports = FilesRenameCommand;