-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathupdate.ts
29 lines (22 loc) · 907 Bytes
/
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
import { Device, DeviceIntegrationType, DeviceUpdate } from '@smartthings/core-sdk'
import { APICommand, chooseDevice, inputAndOutputItem } from '@smartthings/cli-lib'
import { buildTableOutput } from '../../lib/commands/devices-util'
export default class VirtualDeviceUpdateCommand extends APICommand<typeof VirtualDeviceUpdateCommand.flags> {
static description = "update a virtual device's label and room"
static flags = {
...APICommand.flags,
...inputAndOutputItem.flags,
}
static args = [
{
name: 'id',
description: 'the device id',
},
]
async run(): Promise<void> {
const id = await chooseDevice(this, this.args.id, { deviceListOptions: { type: DeviceIntegrationType.VIRTUAL } })
await inputAndOutputItem<DeviceUpdate, Device>(this,
{ buildTableOutput: data => buildTableOutput(this.tableGenerator, data) },
(_, data) => this.client.devices.update(id, data))
}
}