|
11 | 11 | * governing permissions and limitations under the License.
|
12 | 12 | */
|
13 | 13 |
|
14 |
| -import { inBrowser } from '@nimbella/nimbella-deployer' |
15 | 14 | import { NimBaseCommand, NimLogger } from '../../NimBaseCommand'
|
16 |
| -import RuntimeBaseCommand from '@adobe/aio-cli-plugin-runtime/src/RuntimeBaseCommand' |
17 |
| -import { prompt } from '../../ui' |
18 |
| -import { flags } from '@oclif/command' |
19 |
| -const AioCommand: typeof RuntimeBaseCommand = require('@adobe/aio-cli-plugin-runtime/src/commands/runtime/action/delete') |
| 15 | +import { getCredentials, authPersister, deleteAction } from '@nimbella/nimbella-deployer' |
| 16 | +import openwhisk from 'openwhisk' |
20 | 17 |
|
21 | 18 | export default class ActionDelete extends NimBaseCommand {
|
22 | 19 | async runCommand(rawArgv: string[], argv: string[], args: any, flags: any, logger: NimLogger): Promise<void> {
|
23 |
| - if (inBrowser && flags.json) { // behave correctly when invoked from sidecar delete button |
24 |
| - if (!flags.force) { |
25 |
| - const ans = await prompt(`type 'yes' to really delete '${args.actionName}'`) |
26 |
| - if (ans !== 'yes') { |
27 |
| - logger.log('doing nothing') |
28 |
| - return |
29 |
| - } |
30 |
| - } |
| 20 | + const arg = args.actionName |
| 21 | + const creds = await getCredentials(authPersister).catch(err => logger.handleError('', err)) |
| 22 | + const owClient = openwhisk(creds.ow) |
| 23 | + const deletedAction = await deleteAction(arg, owClient) |
| 24 | + if (flags.json) { |
| 25 | + logger.logJSON(deletedAction) |
31 | 26 | }
|
32 |
| - await this.runAio(rawArgv, argv, args, flags, logger, AioCommand) |
33 | 27 | }
|
34 | 28 |
|
35 |
| - static args = AioCommand.args |
| 29 | + static args = [ |
| 30 | + { |
| 31 | + name: 'actionName', |
| 32 | + required: true |
| 33 | + } |
| 34 | + ] |
36 | 35 |
|
37 | 36 | static flags = {
|
38 |
| - force: flags.boolean({ char: 'f', description: 'Just do it, omitting confirmatory prompt' }), |
39 |
| - ...AioCommand.flags |
| 37 | + ...NimBaseCommand.flags // includes json flag |
40 | 38 | }
|
41 | 39 |
|
42 |
| - static description = AioCommand.description |
| 40 | + static description = 'deletes an action' |
43 | 41 | }
|
0 commit comments