-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathupdate.ts
34 lines (26 loc) · 1.31 KB
/
update.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
import { DevicePreference } from '@smartthings/core-sdk'
import { APIOrganizationCommand, inputAndOutputItem } from '@smartthings/cli-lib'
import { chooseDevicePreference, tableFieldDefinitions } from '../../lib/commands/devicepreferences/devicepreferences-util'
export default class DevicePreferencesUpdateCommand extends APIOrganizationCommand {
static description = 'update a device preference'
static flags = {
...APIOrganizationCommand.flags,
...inputAndOutputItem.flags,
}
static args = [{
name: 'id',
description: 'the device preference id',
}]
static aliases = ['device-preferences:update']
static examples = [
'$ smartthings devicepreferences:update -i dp.json # update a device preference with data from dp.json, select which preference from a list',
'$ smartthings devicepreferences:update -i dp.yaml my-preference-id # update device preference my-preference-id with data from dp.yaml',
]
async run(): Promise<void> {
const { args, argv, flags } = await this.parse(DevicePreferencesUpdateCommand)
await super.setup(args, argv, flags)
const id = await chooseDevicePreference(this, args.id)
await inputAndOutputItem<DevicePreference, DevicePreference>(this, { tableFieldDefinitions },
(_, devicePreference) => this.client.devicePreferences.update(id, devicePreference))
}
}