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

Function handler

src/commands/capabilities/create.ts:340–363  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

338}
339
340const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
341 const command = await apiOrganizationCommand(argv)
342
343 const params: HttpClientParams = {}
344 if (argv.namespace) {
345 params.namespace = argv.namespace
346 }
347
348 const createCapability = async (_: void, capability: CapabilityCreate): Promise<Capability> => {
349 return command.client.capabilities.create(capability, params)
350 .catch(error => {
351 if (error.response?.status == 403 && argv.namespace) {
352 return fatalError('Unable to create capability under specified namespace. ' +
353 'Either the namespace does not exist or you do not have permission.')
354 }
355
356 throw error
357 })
358 }
359
360 await inputAndOutputItem(command,
361 { buildTableOutput: data => buildTableOutput(command.tableGenerator, data) },
362 createCapability, userInputProcessor(() => getInputFromUser({ dryRun: !!argv.dryRun })))
363}
364
365const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
366export default cmd

Callers

nothing calls this directly

Calls 5

apiOrganizationCommandFunction · 0.85
inputAndOutputItemFunction · 0.85
userInputProcessorFunction · 0.85
getInputFromUserFunction · 0.70
buildTableOutputFunction · 0.50

Tested by

no test coverage detected