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

Function handler

src/commands/devicepreferences.ts:78–108  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

76 .epilog(buildEpilog({ command, apiDocs: ['listPreferences', 'getPreferenceById'] }))
77
78const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
79 const command = await apiOrganizationCommand(argv)
80 const listTableFieldDefinitions: TableFieldDefinition<DevicePreference & WithOrganization>[] =
81 ['preferenceId', 'title', 'name', 'description', 'required', 'preferenceType']
82 const config: OutputItemOrListConfig<DevicePreference & WithOrganization> = {
83 itemName: 'device preference',
84 primaryKeyName: 'preferenceId',
85 sortKeyName: 'preferenceId',
86 tableFieldDefinitions,
87 listTableFieldDefinitions,
88 }
89
90 await outputItemOrList<DevicePreference & WithOrganization>(
91 command,
92 config,
93 argv.idOrIndex,
94 async () => {
95 if (argv.standard) {
96 return standardPreferences(command)
97 } else if (argv.namespace) {
98 return command.client.devicePreferences.list(argv.namespace)
99 }
100 else if (argv.allOrganizations) {
101 listTableFieldDefinitions.push('organization')
102 return preferencesForAllOrganizations(command)
103 }
104 return customPreferences(command)
105 },
106 id => command.client.devicePreferences.get(id),
107 )
108}
109
110const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
111export default cmd

Callers

nothing calls this directly

Calls 4

apiOrganizationCommandFunction · 0.85
standardPreferencesFunction · 0.85
customPreferencesFunction · 0.85

Tested by

no test coverage detected