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

Function handler

src/commands/locations/history.ts:46–71  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

44 .epilog(buildEpilog({ command }))
45
46const 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 id = await chooseLocation(command, argv.idOrIndex, { autoChoose: true, allowIndex: true })
53 const params = {
54 locationId: id,
55 limit: perRequestLimit,
56 before: toEpochTime(argv.before),
57 after: toEpochTime(argv.after),
58 }
59
60 if (calculateOutputFormat(argv) === 'common') {
61 if (limit > perRequestLimit) {
62 console.log(`History is limited to ${maxItemsPerRequest} items per request.`)
63 }
64 const history = await command.client.history.devices(params)
65 await writeDeviceEventsTable(command, history, { includeName: true, utcTimeFormat: argv.utc })
66 } else {
67 const items = await getHistory(command.client, limit, perRequestLimit, params)
68 const outputFormatter = buildOutputFormatter<DeviceActivity[]>(argv, command.cliConfig)
69 await writeOutput(outputFormatter(items), argv.output)
70 }
71}
72
73const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
74export default cmd

Callers

nothing calls this directly

Calls 8

apiCommandFunction · 0.85
calculateRequestLimitFunction · 0.85
toEpochTimeFunction · 0.85
calculateOutputFormatFunction · 0.85
writeDeviceEventsTableFunction · 0.85
getHistoryFunction · 0.85
buildOutputFormatterFunction · 0.85
writeOutputFunction · 0.85

Tested by

no test coverage detected