-
Notifications
You must be signed in to change notification settings - Fork 104
/
create.ts
33 lines (26 loc) · 1.26 KB
/
create.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 DevicePreferencesTranslationsCreateCommand extends APIOrganizationCommand<typeof DevicePreferencesTranslationsCreateCommand.flags> {
static description = 'create a device preference translation'
static flags = {
...APIOrganizationCommand.flags,
...inputAndOutputItem.flags,
}
static args = [{
name: 'preferenceId',
description: 'device preference id or index',
}]
static examples = [
{
description: 'create a device preference translation as defined in the file preferenceTranslation.json',
command: 'smartthings devicepreferences:translations:create -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.createTranslations(preferenceId, translation))
}
}