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

Function handler

src/commands/edge/drivers/install.ts:44–73  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

42 .epilog(buildEpilog({ command, apiDocs: 'installDrivers' }))
43
44const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
45 const command = await apiCommand(argv)
46
47 const chooseChannelFromEnrollments = async (hubId: string): Promise<string> => {
48 const config: SelectFromListConfig<EnrolledChannel> = {
49 itemName: 'hub-enrolled channel',
50 primaryKeyName: 'channelId',
51 sortKeyName: 'name',
52 }
53 const listItems = (): Promise<EnrolledChannel[]> => command.client.hubdevices.enrolledChannels(hubId)
54 return selectFromList(
55 command,
56 config,
57 { listItems, promptMessage: 'Select a channel to install the driver from.' },
58 )
59 }
60 const hubId = await chooseHub(
61 command,
62 argv.hub,
63 { promptMessage: 'Select a hub to install to.', useConfigDefault: true },
64 )
65 const channelId = argv.channel ?? await chooseChannelFromEnrollments(hubId)
66 const driverId = await chooseDriverFromChannelFn(channelId)(
67 command,
68 argv.driver,
69 { promptMessage: 'Select a driver to install.' },
70 )
71 await command.client.hubdevices.installDriver(driverId, hubId, channelId)
72 console.log(`driver ${driverId} installed to hub ${hubId}`)
73}
74
75const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
76export default cmd

Callers

nothing calls this directly

Calls 3

apiCommandFunction · 0.85

Tested by

no test coverage detected