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

Function handler

src/commands/edge/drivers/installed.ts:54–86  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

52 .epilog(buildEpilog({ command, apiDocs: ['listHubInstalledDrivers', 'getHubDeviceDriver'] }))
53
54const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
55 const command = await apiCommand(argv)
56
57 const config: OutputItemOrListConfig<InstalledDriver & WithNamedChannel> = {
58 primaryKeyName: 'driverId',
59 sortKeyName: 'name',
60 tableFieldDefinitions: ['name', 'driverId', 'description', 'version', 'channelId',
61 'developer', 'vendorSupportInformation'],
62 listTableFieldDefinitions: ['name', 'driverId', 'version', 'channelId'],
63 }
64 if (argv.verbose) {
65 config.tableFieldDefinitions.splice(4, 0, 'channelName')
66 config.listTableFieldDefinitions.splice(3, 0, 'channelName')
67 }
68 const listInstalledWrapper: (drivers: Promise<InstalledDriver[]>) => Promise<(InstalledDriver & WithNamedChannel)[]> =
69 argv.verbose ? async drivers => withChannelNames(command.client, await drivers) : drivers => drivers
70 const getInstalledWrapper: (driver: Promise<InstalledDriver>) => Promise<InstalledDriver & WithNamedChannel> =
71 argv.verbose ? async driver => withChannelNames(command.client, await driver) : driver => driver
72
73 const hubId = await chooseHub(
74 command,
75 argv.hub,
76 { promptMessage: 'Select a hub.', allowIndex: true, useConfigDefault: true },
77 )
78
79 await outputItemOrList(
80 command,
81 config,
82 argv.idOrIndex,
83 () => listInstalledWrapper(command.client.hubdevices.listInstalled(hubId, argv.device)),
84 id => getInstalledWrapper(command.client.hubdevices.getInstalled(hubId, id)),
85 )
86}
87
88const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
89export default cmd

Callers

nothing calls this directly

Calls 3

apiCommandFunction · 0.85
withChannelNamesFunction · 0.85
outputItemOrListFunction · 0.85

Tested by

no test coverage detected