MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / handler

Function handler

src/commands/locations/rooms.ts:52–78  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

50 .epilog(buildEpilog({ command, apiDocs: ['listRooms', 'getRoom'] }))
51
52const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
53 const command = await apiCommand(argv)
54
55 const config: OutputItemOrListConfig<Room & WithNamedLocation> = {
56 primaryKeyName: 'roomId',
57 sortKeyName: 'name',
58 listTableFieldDefinitions: tableFieldDefinitions,
59 tableFieldDefinitions: tableFieldDefinitions,
60 }
61 if (argv.verbose) {
62 config.listTableFieldDefinitions = tableFieldDefinitionsWithLocationName
63 config.tableFieldDefinitions = tableFieldDefinitionsWithLocationName
64 }
65 const rooms = await getRoomsWithLocation(command.client, argv.location)
66 await outputItemOrList<Room & WithNamedLocation>(
67 command,
68 config,
69 argv.idOrIndex,
70 async () => rooms,
71 async id => {
72 const room = rooms.find(room => room.roomId === id)
73 if (!room) {
74 return fatalError(`Could not find room with id ${id}.`)
75 }
76 return room
77 })
78}
79
80const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
81export default cmd

Callers

nothing calls this directly

Calls 3

apiCommandFunction · 0.85
getRoomsWithLocationFunction · 0.85
fatalErrorFunction · 0.85

Tested by

no test coverage detected