diff --git a/CHANGELOG.md b/CHANGELOG.md index f0cb6caf..b82676c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Next Release + +**New Features and Enhancements** + +- Add ability to add an option to a metadata template multi select field ([#230](https://github.com/box/boxcli/pull/230)) + ## 2.8.0 (2020-12-03) **Warning:** diff --git a/src/commands/metadata-templates/update.js b/src/commands/metadata-templates/update.js index f851750e..92781632 100644 --- a/src/commands/metadata-templates/update.js +++ b/src/commands/metadata-templates/update.js @@ -90,6 +90,7 @@ const FLAG_HANDLERS = Object.freeze({ switch (currentOp.op) { case 'addEnumOption': case 'editEnumOption': + case 'addMultiSelectOption': currentOp.data.key = value.input; break; case 'reorderEnumOptions': @@ -228,6 +229,15 @@ const FLAG_HANDLERS = Object.freeze({ }, }; }, + 'add-multi-select-option': (value, currentOp, ops) => { + ops.push(currentOp); + + return { + op: 'addMultiSelectOption', + fieldKey: value.input, + data: {}, + }; + }, }); /** @@ -301,6 +311,10 @@ MetadataTemplatesUpdateCommand.flags = { description: 'Add a multi-select field with the provided display name', multiple: true, }), + 'add-multi-select-option': flags.string({ + description: 'Add an option to a specified multiselect field; must be followed by one or more --option flags', + multiple: true, + }), 'field-key': flags.string({ description: 'Set the key of a field', multiple: true, diff --git a/test/commands/metadata-templates.test.js b/test/commands/metadata-templates.test.js index ebdc485a..4c772785 100644 --- a/test/commands/metadata-templates.test.js +++ b/test/commands/metadata-templates.test.js @@ -439,6 +439,13 @@ describe('Metadata Templates', () => { ] } }, + { + op: 'addMultiSelectOption', + fieldKey: 'foo', + data: { + key: 'bas', + }, + }, { op: 'addField', data: { @@ -488,6 +495,8 @@ describe('Metadata Templates', () => { '--option=bar', '--option=baz', '--no-hidden', + '--add-multi-select-option=foo', + '--option=bas', '--number=Count', '--date=Date', '--json',