diff --git a/src/base-commands/twilio-api-command.js b/src/base-commands/twilio-api-command.js index 1dc26c090..62056b0a9 100644 --- a/src/base-commands/twilio-api-command.js +++ b/src/base-commands/twilio-api-command.js @@ -105,7 +105,8 @@ TwilioApiCommand.setUpNewCommandClass = (NewCommandClass) => { // 'remove' commands have no response body and thus do not need display properties. if (NewCommandClass.actionDefinition.commandName !== 'remove') { - const defaultProperties = (resource && resource.defaultOutputProperties) || []; + const defaultProperties = + (action && action.defaultOutputProperties) || (resource && resource.defaultOutputProperties) || []; cmdFlags.properties = flags.string({ // Camel-cased, CSV of the provided property list. Or just the SID. diff --git a/test/base-commands/twilio-api-command.test.js b/test/base-commands/twilio-api-command.test.js index 4f4bd5305..0f9b813b8 100644 --- a/test/base-commands/twilio-api-command.test.js +++ b/test/base-commands/twilio-api-command.test.js @@ -58,6 +58,37 @@ describe('base-commands', () => { }, }; + // where default output is property is defined at operation level. + const createNewFactorActionDefinition = { + domainName: 'verify', + commandName: 'post', + path: '/v2/Services/{ServiceSid}/Entities/{Identity}/Factors', + resource: fakeResource, + actionName: 'post', + action: { + parameters: [ + { name: 'Identity', in: 'path', schema: { type: 'string' } }, + { name: 'ServiceSid', in: 'path', schema: { type: 'string' } }, + ], + defaultOutputProperties: ['sid', 'binding'], + }, + }; + + const getFactorListActionDefinition = { + domainName: 'verify', + commandName: 'list', + path: '/v2/Services/{ServiceSid}/Entities/{Identity}/Factors', + resource: fakeResource, + actionName: 'get', + action: { + parameters: [ + { name: 'Identity', in: 'path', schema: { type: 'string' } }, + { name: 'ServiceSid', in: 'path', schema: { type: 'string' } }, + { name: 'PageSize', in: 'query', schema: { type: 'integer' } }, + ], + }, + }; + const syncMapItemUpdateActionDefinition = { domainName: 'sync', commandName: 'update', @@ -157,6 +188,15 @@ describe('base-commands', () => { expect(NewCommandClass.flags.properties).to.be.undefined; }); + test.it('check default output property propagation at operation level', () => { + const NewCommandClass = getCommandClass(createNewFactorActionDefinition); + expect(NewCommandClass.flags.properties.default).to.equal('sid,binding'); + }); + test.it('fallback to default output property at path level if not specified at operation level', () => { + const NewCommandClass = getCommandClass(getFactorListActionDefinition); + expect(NewCommandClass.flags.properties.default).to.equal('sid,friendly_name,status'); + }); + test .twilioFakeProfile(ConfigData) .twilioCliEnv(Config)