diff --git a/src/commands/runtime/action/list.js b/src/commands/runtime/action/list.js index dca5cf96..22e9cfb2 100644 --- a/src/commands/runtime/action/list.js +++ b/src/commands/runtime/action/list.js @@ -16,10 +16,16 @@ const { cli } = require('cli-ux') class ActionList extends RuntimeBaseCommand { async run () { - const { flags } = this.parse(ActionList) + const { flags, args } = this.parse(ActionList) + const options = { + ...flags + } + if (args.package) { + options.id = `${args.package}/` + } try { const ow = await this.wsk() - const result = await ow.actions.list(flags) + const result = await ow.actions.list(options) if (flags['name-sort'] || flags.name) { result.sort((a, b) => a.name.localeCompare(b.name)) } @@ -51,6 +57,13 @@ class ActionList extends RuntimeBaseCommand { } } +ActionList.args = [ + { + name: 'package', + required: false + } +] + ActionList.flags = { ...RuntimeBaseCommand.flags, // example usage: aio runtime:action:list --limit 10 --skip 2 diff --git a/test/commands/runtime/action/list.test.js b/test/commands/runtime/action/list.test.js index 18e7e0fe..d682daa6 100644 --- a/test/commands/runtime/action/list.test.js +++ b/test/commands/runtime/action/list.test.js @@ -46,7 +46,7 @@ describe('List command meta', () => { }) test('args', async () => { - expect(TheCommand.args).toBeUndefined() + expect(TheCommand.args).toBeDefined() }) }) @@ -82,6 +82,16 @@ describe('instance methods', () => { }) }) + test('return list of actions in a package', () => { + const cmd = ow.mockResolvedFixture(owAction, 'action/list.json') + command.argv = ['somepackage'] + return command.run() + .then(() => { + expect(cmd).toHaveBeenCalledWith(expect.objectContaining({ id: 'somepackage/' })) + expect(stdout.output).toMatchFixture('action/list-output.txt') + }) + }) + test('return list of actions - coverage (public/private)', () => { const json = fixtureJson('action/list.json') json[0].publish = true