-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathmove.js
48 lines (40 loc) · 1.07 KB
/
move.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
'use strict';
const BoxCommand = require('../../box-command');
const { Flags, Args } = require('@oclif/core');
class FilesMoveCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(FilesMoveCommand);
let updates = {
parent: {
id: args.parentID
}
};
if (flags.etag) {
updates.etag = flags.etag;
}
let movedFile = await this.client.files.update(args.id, updates);
await this.output(movedFile);
}
}
FilesMoveCommand.description = 'Move a file to a different folder';
FilesMoveCommand.examples = ['box files:move 11111 22222'];
FilesMoveCommand._endpoint = 'put_files_id move';
FilesMoveCommand.flags = {
...BoxCommand.flags,
etag: Flags.string({ description: 'Only move if etag value matches' })
};
FilesMoveCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the file to move',
}),
parentID: Args.string({
name: 'parentID',
required: true,
hidden: false,
description: 'ID of the new parent folder to move the file into',
}),
};
module.exports = FilesMoveCommand;