-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathcreate.ts
27 lines (23 loc) · 943 Bytes
/
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
import { Flags } from '@oclif/core'
import { Room, RoomRequest } from '@smartthings/core-sdk'
import { APICommand, CommonOutputProducer, inputAndOutputItem } from '@smartthings/cli-lib'
import { chooseLocation } from '../../locations'
import { tableFieldDefinitions } from '../../../lib/commands/locations/rooms-util'
export default class RoomsCreateCommand extends APICommand<typeof RoomsCreateCommand.flags> {
static description = 'create a room'
static flags = {
...APICommand.flags,
...inputAndOutputItem.flags,
location: Flags.string({
char: 'l',
description: 'a specific location to query',
helpValue: '<UUID>',
}),
}
async run(): Promise<void> {
const locationId = await chooseLocation(this, this.flags.location)
const config: CommonOutputProducer<Room> = { tableFieldDefinitions }
await inputAndOutputItem<RoomRequest, Room>(this, config,
(_, room) => this.client.rooms.create(room, locationId))
}
}