MCPcopy Index your code
hub / github.com/SmartThingsCommunity/smartthings-cli / handler

Function handler

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

Source from the content-addressed store, hash-verified

75 .epilog(buildEpilog({ command }))
76
77const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
78 const command = await apiCommand(argv)
79
80 const config: OutputItemOrListConfig<Device & WithNamedRoom> = {
81 primaryKeyName: 'deviceId',
82 sortKeyName: 'label',
83 listTableFieldDefinitions: ['label', 'deviceId'],
84 buildTableOutput: (data: Device) => buildTableOutput(command.tableGenerator, data),
85 }
86 if (argv.verbose) {
87 config.listTableFieldDefinitions.splice(3, 0, 'location', 'room')
88 }
89
90 const deviceListOptions: DeviceListOptions = {
91 locationId: argv.location,
92 installedAppId: argv.installedApp,
93 type: DeviceIntegrationType.VIRTUAL,
94 }
95
96 await outputItemOrList<Device & WithNamedRoom>(
97 command,
98 config,
99 argv.idOrIndex,
100 async () => {
101 const devices = await command.client.devices.list(deviceListOptions)
102 if (argv.verbose) {
103 return await withLocationsAndRooms(command.client, devices)
104 }
105 return devices
106 },
107 id => command.client.devices.get(id),
108 )
109}
110
111const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
112export default cmd

Callers

nothing calls this directly

Calls 3

apiCommandFunction · 0.85
withLocationsAndRoomsFunction · 0.85
buildTableOutputFunction · 0.50

Tested by

no test coverage detected