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

Function handler

src/commands/deviceprofiles.ts:56–90  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

54 .epilog(buildEpilog({ command, apiDocs: ['listDeviceProfiles', 'getDeviceProfile'] }))
55
56const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
57 const command = await apiOrganizationCommand(argv)
58
59 const config: OutputItemOrListConfig<DeviceProfile & WithOrganization> = {
60 primaryKeyName: 'id',
61 sortKeyName: 'name',
62 listTableFieldDefinitions: ['name', 'status', 'id'],
63 buildTableOutput: (data: DeviceProfile) => buildTableOutput(command.tableGenerator, data),
64 }
65
66 if (argv.allOrganizations) {
67 config.listTableFieldDefinitions = ['name', 'status', 'id', 'organization']
68 }
69
70 if (argv.verbose) {
71 config.listTableFieldDefinitions.push({
72 label: 'Profile Id',
73 value: item => item.metadata?.vid ?? '',
74 })
75 config.listTableFieldDefinitions.push({
76 label: 'Manufacturer Name',
77 value: item => item.metadata?.mnmn ?? '',
78 })
79 }
80
81 await outputItemOrList<DeviceProfile & WithOrganization>(
82 command,
83 config,
84 argv.idOrIndex,
85 () => argv.allOrganizations
86 ? forAllOrganizations(command.client, (orgClient) => orgClient.deviceProfiles.list())
87 : command.client.deviceProfiles.list(),
88 id => command.client.deviceProfiles.get(id),
89 )
90}
91
92const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
93export default cmd

Callers

nothing calls this directly

Calls 3

apiOrganizationCommandFunction · 0.85
forAllOrganizationsFunction · 0.85
buildTableOutputFunction · 0.50

Tested by

no test coverage detected