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

Function builder

src/commands/devices/commands.ts:25–44  ·  view source on GitHub ↗
(yargs: Argv)

Source from the content-addressed store, hash-verified

23const describe = 'execute a device command'
24
25const builder = (yargs: Argv): Argv<CommandArgs> =>
26 inputItemBuilder(apiCommandBuilder(yargs))
27 .positional('id', { describe: 'the device id', type: 'string' })
28 .positional(
29 'command',
30 { describe: 'the command [<component>]:<capability>:<command>([<arguments>])', type: 'string' },
31 )
32 .example([
33 ['$0 devices:commands', 'prompt for a device and details of the command to send'],
34 [
35 '$0 devices:commands 82532e8c-e35b-4fa8-b45f-58a083e5f3d2 switch:off',
36 'send the "off" command for the "switch" capability to the specified device',
37 ],
38 [
39 '$0 devices:commands 6d73e4d1-3278-44d4-915a-099a62f05330 \'switchLevel:setLevel(50)\'',
40 'send the "setLevel" command, passing 50 as an argument, for the "switchLevel" capability to the' +
41 ' specified device (note: quotes prevent shell parsing errors)',
42 ],
43 ])
44 .epilog(buildEpilog({ command, apiDocs: ['executeDeviceCommands'] }))
45
46const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
47 const command = await apiCommand(argv)

Callers

nothing calls this directly

Calls 2

apiCommandBuilderFunction · 0.85
buildEpilogFunction · 0.85

Tested by

no test coverage detected