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

Function handler

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

Source from the content-addressed store, hash-verified

66 .epilog(buildEpilog({ command }))
67
68const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
69 const command = await apiOrganizationCommand(argv)
70
71 const deviceProfileId = await chooseDeviceProfileFn({ verbose: argv.verbose })(
72 command,
73 argv.profileIdOrIndex,
74 { allowIndex: true },
75 )
76
77 const config: OutputItemOrListConfig<DeviceProfileTranslations, LocaleReference> = {
78 primaryKeyName: 'tag',
79 sortKeyName: 'tag',
80 buildTableOutput: data => buildTableOutput(command.tableGenerator, data),
81 listTableFieldDefinitions: ['tag'],
82 }
83 await outputItemOrList<DeviceProfileTranslations, LocaleReference>(
84 command,
85 config,
86 argv.tag,
87 async () => await command.client.deviceProfiles.listLocales(deviceProfileId).catch(error => {
88 if (error.response?.status === 404) {
89 return []
90 }
91 throw error
92 }),
93 async tag => await command.client.deviceProfiles.getTranslations(deviceProfileId, tag).catch(error => {
94 if (error.response?.status === 404) {
95 return fatalError(`No ${tag} translation exists for device profile ${deviceProfileId}.`)
96 }
97 throw error
98 }),
99 )
100}
101
102const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
103export default cmd

Callers

nothing calls this directly

Calls 4

apiOrganizationCommandFunction · 0.85
chooseDeviceProfileFnFunction · 0.85
fatalErrorFunction · 0.85
buildTableOutputFunction · 0.50

Tested by

no test coverage detected