-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdelete.js
46 lines (37 loc) · 1.32 KB
/
delete.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { Args } = require('@oclif/core')
const { deleteProject } = require('../../requests/project')
const { getProjectIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
const BaseCommand = require('../../support/command/base-command')
class DeleteProjectCommand extends BaseCommand {
constructor(...props) {
super(...props)
this.setSuccessMessage('ProjectDelete')
}
async run() {
const { args } = await this.parse(DeleteProjectCommand)
const projectPath = getProjectIdentifierArg(args)
await this.deleteProject(projectPath)
}
async deleteProject(projectPath) {
const [owner, projectName] = splitPathParams(projectPath)
return this.executeHttp({
execute: () => deleteProject([owner, projectName]),
onResolve: this.logCommandSuccess({ projectPath }),
options: {}
})
}
}
DeleteProjectCommand.description = 'Deletes a project from SwaggerHub.'
DeleteProjectCommand.examples = [
'swaggerhub project:delete organization/project_name'
]
DeleteProjectCommand.args = {
'OWNER/PROJECT_NAME': Args.string({
required: true,
description: 'The project to delete on Swaggerhub'
})
}
DeleteProjectCommand.flags = {
...BaseCommand.flags
}
module.exports = DeleteProjectCommand