Skip to content

Commit

Permalink
adding ability to limit action list by package. fixes #105 (#109)
Browse files Browse the repository at this point in the history
* adding ability to limit action list by package. fixes #105
  • Loading branch information
justinedelson authored Feb 8, 2020
1 parent ac148cc commit 3ceba9e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/commands/runtime/action/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion test/commands/runtime/action/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('List command meta', () => {
})

test('args', async () => {
expect(TheCommand.args).toBeUndefined()
expect(TheCommand.args).toBeDefined()
})
})

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3ceba9e

Please sign in to comment.