-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathset.js
53 lines (44 loc) · 1.6 KB
/
set.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
'use strict';
const BoxCommand = require('../../../box-command');
const { Flags, Args } = require('@oclif/core');
const utils = require('../../../util');
class FoldersSetMetadataCommand extends BoxCommand {
async run() {
const { flags, args } = await this.parse(FoldersSetMetadataCommand);
let metadataValues = Object.assign({}, ...flags.data);
let templateKey = flags['template-key'];
let metadata = await this.client.folders.setMetadata(args.id, flags.scope, templateKey, metadataValues);
await this.output(metadata);
}
}
FoldersSetMetadataCommand.description = 'Set metadata on a folder';
FoldersSetMetadataCommand.examples = [
'box folders:metadata:set 22222 --template-key employeeRecord --data "name=John Doe" --data department=Sales',
'box folders:metadata:set 22222 --template-key myTemplate --data "multiselectkey1=[option1A,option1B]" --data "multiselectkey2=[option2A]"',
];
FoldersSetMetadataCommand.flags = {
...BoxCommand.flags,
data: Flags.string({
description: 'Metadata key and value, in the form "key=value". Note: For float type, use "#" at the beginning of digits: key2=#1234.50',
required: true,
multiple: true,
parse: utils.parseMetadata,
}),
scope: Flags.string({
description: 'The scope of the metadata template to use',
default: 'enterprise',
}),
'template-key': Flags.string({
description: 'The key of the metadata template to use',
required: true,
}),
};
FoldersSetMetadataCommand.args = {
id: Args.string({
name: 'id',
required: true,
hidden: false,
description: 'ID of the folder to add metadata to',
}),
};
module.exports = FoldersSetMetadataCommand;