Skip to content

Commit

Permalink
adding ability to limit action list by package. fixes #105
Browse files Browse the repository at this point in the history
  • Loading branch information
justinedelson committed Feb 6, 2020
1 parent 4ca14ee commit 1011e21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/commands/runtime/action/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const { cli } = require('cli-ux')
class ActionList extends RuntimeBaseCommand {
async run () {
const { flags } = this.parse(ActionList)
if (flags.package) {
flags.id = `${flags.package}/`
delete flags.package
}
try {
const ow = await this.wsk()
const result = await ow.actions.list(flags)
Expand Down Expand Up @@ -71,6 +75,10 @@ ActionList.flags = {
name: flags.boolean({
char: 'n',
description: 'sort results by name'
}),
package: flags.string({
char: 'p',
description: 'limit results to a specific package'
})
}

Expand Down
10 changes: 10 additions & 0 deletions test/commands/runtime/action/list.test.js
Original file line number Diff line number Diff line change
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 = ['--package', '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 1011e21

Please sign in to comment.