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

Function handler

src/commands/virtualdevices/events.ts:60–77  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

58 }))
59
60const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
61 const command = await apiCommand(argv)
62
63 const deviceId = await chooseDeviceFn({ type: DeviceIntegrationType.VIRTUAL })(command, argv.deviceId)
64
65 const createEvents = async (_: void, input: DeviceEvent[]): Promise<EventInputOutput[]> => {
66 const output = await command.client.virtualDevices.createEvents(deviceId, input)
67 return input.map((event, index) => ({ event, stateChange: output.stateChanges[index] }))
68 }
69 // TODO: This really should provide separate input processors for command line input and
70 // user input rather than doing it all in `getInputFromUser`
71 await inputAndOutputItem<DeviceEvent[], EventInputOutput[]>(
72 command,
73 { buildTableOutput: (data: EventInputOutput[]) => buildTableOutput(command.tableGenerator, data) },
74 createEvents,
75 userInputProcessor(() => getInputFromUser(command, argv, deviceId)),
76 )
77}
78
79const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
80export default cmd

Callers

nothing calls this directly

Calls 5

apiCommandFunction · 0.85
chooseDeviceFnFunction · 0.85
userInputProcessorFunction · 0.85
getInputFromUserFunction · 0.70
buildTableOutputFunction · 0.50

Tested by

no test coverage detected