-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlist.js
More file actions
63 lines (54 loc) · 1.66 KB
/
Copy pathlist.js
File metadata and controls
63 lines (54 loc) · 1.66 KB
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
54
55
56
57
58
59
60
61
62
63
const { ux, Args } = require('@oclif/core')
const { getApi } = require('../../requests/api')
const { getResponseContent } = require('../../support/command/handle-response')
const { getApiIdentifierArg } = require('../../support/command/parse-input')
const BaseCommand = require('../../support/command/base-command')
class ListIntegrationCommand extends BaseCommand {
constructor(...props) {
super(...props)
this.logIntegration = this.logIntegration.bind(this)
}
async run() {
const { args } = await this.parse(ListIntegrationCommand)
const requestedApiPath = getApiIdentifierArg(args)
const apiPath = await this.ensureVersion(requestedApiPath)
await this.listIntegrations(apiPath)
}
async logIntegration(response) {
const { integrations } = JSON.parse(await getResponseContent(response))
ux.table(integrations, {
id: {
header: 'ID',
minWidth: 38
},
name: {},
configType: {
header: 'Type'
},
enabled: {}
}, {
printLine: this.log.bind(this)
})
}
async listIntegrations(apiPath) {
return this.executeHttp({
execute: () => getApi([apiPath, 'integrations']),
onResolve: this.logIntegration,
options: {}
})
}
}
ListIntegrationCommand.description = 'list integrations on an API.'
ListIntegrationCommand.examples = [
'swaggerhub integration:list organization/api/1.0.0'
]
ListIntegrationCommand.args = {
'OWNER/API_NAME/[VERSION]': Args.string({
required: true,
description: 'API to list integrations for on Swaggerhub'
})
}
ListIntegrationCommand.flags = {
...BaseCommand.flags
}
module.exports = ListIntegrationCommand