-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathget.js
53 lines (43 loc) · 1.54 KB
/
get.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
47
48
49
50
51
52
53
const { Args } = require('@oclif/core')
const { getProject } = require('../../requests/project')
const { getProjectIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
const { getResponseContent } = require('../../support/command/handle-response')
const { prettyPrintJSON } = require('../../utils/general')
const BaseCommand = require('../../support/command/base-command')
class GetProjectCommand extends BaseCommand {
constructor(...props) {
super(...props)
this.logProject = this.logProject.bind(this)
}
async run() {
const { args } = await this.parse(GetProjectCommand)
const projectPath = getProjectIdentifierArg(args)
await this.getProject(projectPath)
}
async logProject(response) {
const project = await getResponseContent(response)
this.log(prettyPrintJSON(project))
}
async getProject(projectPath) {
const [owner, project] = splitPathParams(projectPath)
return this.executeHttp({
execute: () => getProject([owner, project]),
onResolve: this.logProject,
options: {}
})
}
}
GetProjectCommand.description = 'Retrieves the details for a project.'
GetProjectCommand.examples = [
'swaggerhub project:get organization/project_name'
]
GetProjectCommand.args = {
'OWNER/PROJECT_NAME': Args.string({
required: true,
description: 'The project to get details for on Swaggerhub'
})
}
GetProjectCommand.flags = {
...BaseCommand.flags
}
module.exports = GetProjectCommand