MCPcopy Index your code
hub / github.com/SmartThingsCommunity/smartthings-cli / handler

Function handler

src/commands/installedapps.ts:67–102  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

65 .epilog(buildEpilog({ command, apiDocs: ['listInstallations', 'getInstallation'] }))
66
67const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
68 const command = await apiCommand(argv)
69
70 const config: OutputItemOrListConfig<InstalledApp & WithNamedLocation> = {
71 primaryKeyName: 'installedAppId',
72 sortKeyName: 'displayName',
73 listTableFieldDefinitions,
74 tableFieldDefinitions,
75 }
76
77 if (argv.verbose) {
78 config.listTableFieldDefinitions.splice(3, 0, 'locationId', 'location')
79 config.tableFieldDefinitions.splice(7, 0, 'location')
80 }
81 const verboseInstalledApp: (app: Promise<InstalledApp>) => Promise<InstalledApp & WithNamedLocation> =
82 argv.verbose ? async app => withLocation(command.client, await app) : app => app
83
84 const installedApps = async (): Promise<(InstalledApp & WithNamedLocation)[]> => {
85 const listOptions: InstalledAppListOptions = {
86 locationId: argv.location,
87 }
88 const apps = await command.client.installedApps.list(listOptions)
89 if (argv.verbose) {
90 return await withLocations(command.client, apps)
91 }
92 return apps
93 }
94
95 await outputItemOrList(
96 command,
97 config,
98 argv.idOrIndex,
99 installedApps,
100 id => verboseInstalledApp(command.client.installedApps.get(id)),
101 )
102}
103
104const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
105export default cmd

Callers

nothing calls this directly

Calls 4

apiCommandFunction · 0.85
withLocationFunction · 0.85
outputItemOrListFunction · 0.85
verboseInstalledAppFunction · 0.85

Tested by

no test coverage detected