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

Function handler

src/commands/deviceprofiles/view.ts:50–74  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

48 .epilog(buildEpilog({ command, apiDocs: ['getDeviceProfile', 'getDeviceConfiguration'] }))
49
50const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
51 const command = await apiOrganizationCommand(argv)
52
53 const getDeviceProfileAndConfig = async (id: string): Promise<DeviceDefinition> => {
54 const profile = await command.client.deviceProfiles.get(id)
55 if (profile.metadata) {
56 try {
57 const view = await command.client.presentation.get(profile.metadata.vid, profile.metadata.mnmn)
58 return { ...profile, view: prunePresentation(view) }
59 } catch (error) {
60 command.logger.warn(error)
61 return profile
62 }
63 }
64 return profile
65 }
66
67 const profileId = await chooseDeviceProfile(command, argv.idOrIndex, { allowIndex: true })
68 const profileAndConfig = await getDeviceProfileAndConfig(profileId)
69 await formatAndWriteItem(
70 command,
71 { buildTableOutput: data => buildTableOutput(command.tableGenerator, data) },
72 profileAndConfig,
73 )
74}
75
76const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
77export default cmd

Callers

nothing calls this directly

Calls 4

apiOrganizationCommandFunction · 0.85
formatAndWriteItemFunction · 0.85
buildTableOutputFunction · 0.50

Tested by

no test coverage detected