(argv: ArgumentsCamelCase<CommandArgs>)
| 44 | .epilog(buildEpilog({ command })) |
| 45 | |
| 46 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 47 | const command = await apiCommand(argv) |
| 48 | |
| 49 | const limit = argv.limit |
| 50 | const perRequestLimit = calculateRequestLimit(limit) |
| 51 | |
| 52 | const deviceId = await chooseDevice(command, argv.idOrIndex, { allowIndex: true }) |
| 53 | const device = await command.client.devices.get(deviceId) |
| 54 | const params = { |
| 55 | deviceId, |
| 56 | locationId: device.locationId, |
| 57 | limit: perRequestLimit, |
| 58 | before: toEpochTime(argv.before), |
| 59 | after: toEpochTime(argv.after), |
| 60 | } |
| 61 | |
| 62 | if (calculateOutputFormat(argv) === 'common') { |
| 63 | if (limit > perRequestLimit) { |
| 64 | console.log(`History is limited to ${maxItemsPerRequest} items per request.`) |
| 65 | } |
| 66 | const history = await command.client.history.devices(params) |
| 67 | await writeDeviceEventsTable(command, history, { utcTimeFormat: argv.utc }) |
| 68 | } else { |
| 69 | const items = await getHistory(command.client, limit, perRequestLimit, params) |
| 70 | const outputFormatter = buildOutputFormatter<DeviceActivity[]>(argv, command.cliConfig) |
| 71 | await writeOutput(outputFormatter(items), argv.output) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 76 | export default cmd |
nothing calls this directly
no test coverage detected