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

Function handler

src/commands/apps.ts:66–98  ·  view source on GitHub ↗
(argv: ArgumentsCamelCase<CommandArgs>)

Source from the content-addressed store, hash-verified

64 .epilog(buildEpilog({ command, apiDocs: ['listApps', 'getApp'] }))
65
66const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
67 const command = await apiCommand(argv)
68
69 const listTableFieldDefinitions: TableFieldDefinition<PagedApp | AppResponse>[] = ['displayName', 'appType', 'appId']
70 if (argv.verbose) {
71 listTableFieldDefinitions.push({ label: 'ARN/URL', value: shortARNorURL })
72 }
73 const config: OutputItemOrListConfig<AppResponse, PagedApp | AppResponse> = {
74 primaryKeyName: 'appId',
75 sortKeyName: 'displayName',
76 tableFieldDefinitions,
77 listTableFieldDefinitions,
78 }
79
80 const listApps = async (): Promise<PagedApp[] | AppResponse[]> => {
81 const appListOptions: AppListOptions = {}
82 if (argv.type) {
83 appListOptions.appType = AppType[argv.type as keyof typeof AppType]
84 }
85
86 if (argv.classification) {
87 appListOptions.classification = argv.classification
88 .map(classification => AppClassification[classification as keyof typeof AppClassification])
89 }
90
91 if (argv.verbose) {
92 return verboseApps(command.client, appListOptions)
93 }
94 return command.client.apps.list(appListOptions)
95 }
96
97 await outputItemOrList(command, config, argv.idOrIndex, listApps, id => command.client.apps.get(id))
98}
99
100const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
101export default cmd

Callers

nothing calls this directly

Calls 2

apiCommandFunction · 0.85
outputItemOrListFunction · 0.85

Tested by

no test coverage detected