(argv: ArgumentsCamelCase<CommandArgs>)
| 75 | .epilog(buildEpilog({ command })) |
| 76 | |
| 77 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 78 | const command = await apiCommand(argv) |
| 79 | |
| 80 | const config: OutputItemOrListConfig<Device & WithNamedRoom> = { |
| 81 | primaryKeyName: 'deviceId', |
| 82 | sortKeyName: 'label', |
| 83 | listTableFieldDefinitions: ['label', 'deviceId'], |
| 84 | buildTableOutput: (data: Device) => buildTableOutput(command.tableGenerator, data), |
| 85 | } |
| 86 | if (argv.verbose) { |
| 87 | config.listTableFieldDefinitions.splice(3, 0, 'location', 'room') |
| 88 | } |
| 89 | |
| 90 | const deviceListOptions: DeviceListOptions = { |
| 91 | locationId: argv.location, |
| 92 | installedAppId: argv.installedApp, |
| 93 | type: DeviceIntegrationType.VIRTUAL, |
| 94 | } |
| 95 | |
| 96 | await outputItemOrList<Device & WithNamedRoom>( |
| 97 | command, |
| 98 | config, |
| 99 | argv.idOrIndex, |
| 100 | async () => { |
| 101 | const devices = await command.client.devices.list(deviceListOptions) |
| 102 | if (argv.verbose) { |
| 103 | return await withLocationsAndRooms(command.client, devices) |
| 104 | } |
| 105 | return devices |
| 106 | }, |
| 107 | id => command.client.devices.get(id), |
| 108 | ) |
| 109 | } |
| 110 | |
| 111 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 112 | export default cmd |
nothing calls this directly
no test coverage detected