(argv: ArgumentsCamelCase<CommandArgs>)
| 61 | } |
| 62 | |
| 63 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 64 | const command = await apiCommand(argv) |
| 65 | |
| 66 | const deviceId = await chooseDevice(command, argv.deviceIdOrIndex, { allowIndex: true }) |
| 67 | |
| 68 | const device = await command.client.devices.get(deviceId) |
| 69 | const chooseComponent = chooseComponentFn(device) |
| 70 | const componentId = await chooseComponent(command, argv.componentId, { autoChoose: true }) |
| 71 | |
| 72 | const component = device.components?.find(component => component.id === componentId) |
| 73 | const capabilities = component?.capabilities |
| 74 | if (!capabilities) { |
| 75 | return fatalError(`no capabilities found for component ${componentId} of device ${deviceId}`) |
| 76 | } |
| 77 | |
| 78 | const config: SelectFromListConfig<CapabilityReference> = { |
| 79 | itemName: 'capability', |
| 80 | pluralItemName: 'capabilities', |
| 81 | primaryKeyName: 'id', |
| 82 | sortKeyName: 'id', |
| 83 | listTableFieldDefinitions: ['id'], |
| 84 | } |
| 85 | const listItems = async (): Promise<CapabilityReference[]> => capabilities |
| 86 | const preselectedId = await stringTranslateToId(config, argv.capabilityId, listItems) |
| 87 | const capabilityId = await selectFromList(command, config, { preselectedId, listItems }) |
| 88 | const capabilityStatus = await command.client.devices.getCapabilityStatus( |
| 89 | deviceId, |
| 90 | componentId, |
| 91 | capabilityId, |
| 92 | ) |
| 93 | await formatAndWriteItem( |
| 94 | command, |
| 95 | { buildTableOutput: data => buildTableOutput(command.tableGenerator, data) }, |
| 96 | capabilityStatus, |
| 97 | ) |
| 98 | } |
| 99 | |
| 100 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 101 | export default cmd |
nothing calls this directly
no test coverage detected