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

Function handler

src/commands/rules/execute.ts:45–59  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

43 .epilog(buildEpilog({ command, apiDocs: ['executeRule'] }))
44
45const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
46 const command = await apiCommand(argv)
47
48 const chooseRule = chooseRuleFn(argv.location)
49 const ruleId = await chooseRule(command, argv.id, { promptMessage: 'Select a rule to execute.' })
50
51 const locationId = argv.location ?? (await getRuleWithLocation(command.client, ruleId, argv.location)).locationId
52
53 const result = await command.client.rules.execute(ruleId, locationId)
54 await formatAndWriteItem<RuleExecutionResponse>(
55 command,
56 { buildTableOutput: data => buildExecuteResponseTableOutput(command.tableGenerator, data) },
57 result,
58 )
59}
60
61const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
62export default cmd

Callers

nothing calls this directly

Calls 4

apiCommandFunction · 0.85
chooseRuleFnFunction · 0.85
getRuleWithLocationFunction · 0.85

Tested by

no test coverage detected