-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathupdate.ts
33 lines (26 loc) · 1.28 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
import { APIOrganizationCommand, inputAndOutputItem } from '@smartthings/cli-lib'
import { PreferenceLocalization } from '@smartthings/core-sdk'
import { chooseDevicePreference } from '../../../lib/commands/devicepreferences-util'
import { tableFieldDefinitions } from '../../../lib/commands/devicepreferences/translations-util'
export default class DevicePreferencesTranslationsUpdateCommand extends APIOrganizationCommand<typeof DevicePreferencesTranslationsUpdateCommand.flags> {
static description = 'update a device preference translation'
static flags = {
...APIOrganizationCommand.flags,
...inputAndOutputItem.flags,
}
static args = [{
name: 'preferenceId',
description: 'device preference id or index',
}]
static examples = [
{
description: 'select a translation from a list and update it with the data in the file preferenceTranslation.json',
command: 'smartthings devicepreferences:translations:update -i preferenceTranslation.json',
},
]
async run(): Promise<void> {
const preferenceId = await chooseDevicePreference(this, this.args.preferenceId)
await inputAndOutputItem<PreferenceLocalization, PreferenceLocalization>(this, { tableFieldDefinitions },
(_, translation) => this.client.devicePreferences.updateTranslations(preferenceId, translation))
}
}