-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathcreate.ts
26 lines (19 loc) · 1.06 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
import { CapabilityPresentation, CapabilityPresentationCreate } from '@smartthings/core-sdk'
import { APIOrganizationCommand, inputAndOutputItem } from '@smartthings/cli-lib'
import { buildTableOutput } from '../presentation'
import { capabilityIdInputArgs, chooseCapability } from '../../../lib/commands/capabilities-util'
export default class CapabilitiesPresentationCreate extends APIOrganizationCommand<typeof CapabilitiesPresentationCreate.flags> {
static description = 'create presentation model for a capability' +
this.apiDocsURL('createCustomCapabilityPresentation')
static flags = {
...APIOrganizationCommand.flags,
...inputAndOutputItem.flags,
}
static args = capabilityIdInputArgs
async run(): Promise<void> {
const id = await chooseCapability(this, this.args.id, this.args.version)
await inputAndOutputItem<CapabilityPresentationCreate, CapabilityPresentation>(this,
{ buildTableOutput: data => buildTableOutput(this.tableGenerator, data) },
(_, presentation) => this.client.capabilities.createPresentation(id.id, id.version, presentation))
}
}