-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathupdate.ts
32 lines (24 loc) · 911 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
30
31
32
import { Device, DeviceUpdate } from '@smartthings/core-sdk'
import { APICommand, inputAndOutputItem } from '@smartthings/cli-lib'
import { buildTableOutput, chooseDevice } from '../../lib/commands/devices/devices-util'
export default class DeviceUpdateCommand extends APICommand {
static description = "get the current status of all of a device's component's attributes"
static flags = {
...APICommand.flags,
...inputAndOutputItem.flags,
}
static args = [
{
name: 'id',
description: 'the device id',
},
]
async run(): Promise<void> {
const { args, argv, flags } = await this.parse(DeviceUpdateCommand)
await super.setup(args, argv, flags)
const id = await chooseDevice(this, args.id)
await inputAndOutputItem<DeviceUpdate, Device>(this,
{ buildTableOutput: data => buildTableOutput(this.tableGenerator, data) },
(_, data) => this.client.devices.update(id, data))
}
}