/
update.ts
29 lines (22 loc) · 901 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 { inputAndOutputItem } from '@smartthings/cli-lib'
import { Channel, ChannelUpdate } from '@smartthings/core-sdk'
import { chooseChannel, tableFieldDefinitions } from '../../../lib/commands/channels-util'
import { EdgeCommand } from '../../../lib/edge-command'
export default class ChannelsUpdateCommand extends EdgeCommand<typeof ChannelsUpdateCommand.flags> {
static description = 'update a channel' +
this.apiDocsURL('updateChannel')
static flags = {
...EdgeCommand.flags,
...inputAndOutputItem.flags,
}
static args = [{
name: 'id',
description: 'the channel id',
}]
async run(): Promise<void> {
const id = await chooseChannel(this, 'Choose a channel to patch.', this.args.id,
{ useConfigDefault: true })
await inputAndOutputItem<ChannelUpdate, Channel>(this, { tableFieldDefinitions },
(_, channelMods) => this.client.channels.update(id, channelMods))
}
}