-
Notifications
You must be signed in to change notification settings - Fork 103
/
oauth.ts
38 lines (32 loc) · 1.16 KB
/
oauth.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
37
38
import { APICommand, outputItem, outputItemOrList } from '@smartthings/cli-lib'
import { chooseApp, oauthTableFieldDefinitions } from '../../lib/commands/apps-util'
export default class AppOauthCommand extends APICommand<typeof AppOauthCommand.flags> {
static description = 'get OAuth information for the app' +
this.apiDocsURL('getAppOauth')
static flags = {
...APICommand.flags,
...outputItemOrList.flags,
}
static args = [{
name: 'id',
description: 'the app id or number in the list',
}]
static examples = [
{
description: 'prompt for an app and list OAuth information for it',
command: 'smartthings apps:oauth',
},
{
description: 'list OAuth information for the second app in the list generated by "smartthings apps"',
command: 'smartthings apps:oauth 2',
},
{
description: 'list OAuth information for the app with the given id',
command: 'smartthings apps:oauth 392bcb11-e251-44f3-b58b-17f93015f3aa',
},
]
async run(): Promise<void> {
const id = await chooseApp(this, this.args.id, { allowIndex: true })
await outputItem(this, { tableFieldDefinitions: oauthTableFieldDefinitions }, () => this.client.apps.getOauth(id))
}
}