-
Notifications
You must be signed in to change notification settings - Fork 102
/
settings.ts
42 lines (35 loc) · 1.32 KB
/
settings.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
39
40
41
42
import { APICommand, CustomCommonOutputProducer, outputItem, outputItemOrList } from '@smartthings/cli-lib'
import { AppSettingsResponse } from '@smartthings/core-sdk'
import { buildTableOutput, chooseApp } from '../../lib/commands/apps-util'
export default class AppSettingsCommand extends APICommand<typeof AppSettingsCommand.flags> {
static description = 'get the settings of an app' +
this.apiDocsURL('getAppSettings')
static flags = {
...APICommand.flags,
...outputItemOrList.flags,
}
static args = [{
name: 'id',
description: 'the app id',
}]
static examples = [
{
description: 'choose an app from a list and get its settings',
command: 'smartthings apps:settings',
},
{
description: 'get the settings of the app with the given id',
command: 'smartthings apps:settings 392bcb11-e251-44f3-b58b-17f93015f3aa',
},
{
description: 'get the settings of the third app in the list generated by "smartthings apps"',
command: 'smartthings apps:settings 3',
},
]
async run(): Promise<void> {
const id = await chooseApp(this, this.args.id, { allowIndex: true })
const config: CustomCommonOutputProducer<AppSettingsResponse> =
{ buildTableOutput: appSettings => buildTableOutput(this.tableGenerator, appSettings) }
await outputItem(this, config, () => this.client.apps.getSettings(id))
}
}