(argv: ArgumentsCamelCase<CommandArgs>)
| 42 | .epilog(buildEpilog({ command, apiDocs: 'installDrivers' })) |
| 43 | |
| 44 | const 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 | |
| 75 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 76 | export default cmd |
nothing calls this directly
no test coverage detected