-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathinfo.ts
36 lines (29 loc) · 1021 Bytes
/
info.ts
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
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import {Args, ux} from '@oclif/core'
export default class ClientsInfo extends Command {
static description = 'show details of an oauth client'
static examples = [
'$ heroku clients:info 36120128-fee7-455e-8b7f-807aee130946',
]
static flags = {
json: flags.boolean({char: 'j', description: 'output in json format'}),
shell: flags.boolean({char: 's', description: 'output in shell format'}),
}
static args = {
id: Args.string({required: true}),
}
async run() {
const {args, flags} = await this.parse(ClientsInfo)
const {body: client} = await this.heroku.get<Heroku.OAuthClient>(`/oauth/clients/${args.id}`)
if (flags.json) {
ux.styledJSON(client)
} else if (flags.shell) {
ux.log(`HEROKU_OAUTH_ID=${client.id}`)
ux.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
} else {
ux.styledHeader(`${client.name}`)
ux.styledObject(client)
}
}
}