1
- import { PresentationDevicePresentation } from '@smartthings/core-sdk'
1
+ import { type PresentationDevicePresentation } from '@smartthings/core-sdk'
2
2
3
- import { APICommand , outputItem , TableGenerator } from '@smartthings/cli-lib '
3
+ import { type TableGenerator } from '../../table-generator.js '
4
4
5
5
6
- export function buildTableOutput ( tableGenerator : TableGenerator , presentation : PresentationDevicePresentation ) : string {
7
- const basicInfo = tableGenerator . buildTableFromItem ( presentation , [
8
- { prop : 'presentationId' , label : 'Presentation ID' } , { prop : 'manufacturerName' , label : 'Manufacturer Name' } , 'iconUrl' ,
9
- ] )
6
+ export const buildTableOutput = (
7
+ tableGenerator : TableGenerator ,
8
+ presentation : PresentationDevicePresentation ,
9
+ ) : string => {
10
+ const basicInfo = tableGenerator . buildTableFromItem (
11
+ presentation ,
12
+ [
13
+ { prop : 'presentationId' , label : 'Presentation ID' } ,
14
+ { prop : 'manufacturerName' , label : 'Manufacturer Name' } ,
15
+ 'iconUrl' ,
16
+ ] ,
17
+ )
10
18
11
19
let dashboardStates = 'No dashboard states'
12
20
if ( presentation . dashboard ?. states && presentation . dashboard . states . length > 0 ) {
@@ -24,15 +32,15 @@ export function buildTableOutput(tableGenerator: TableGenerator, presentation: P
24
32
dashboardStates = `Dashboard States\n${ subTable . toString ( ) } `
25
33
}
26
34
27
- function buildDisplayTypeTable ( items : { displayType : string } [ ] ) : string {
35
+ const buildDisplayTypeTable = ( items : { displayType : string } [ ] ) : string => {
28
36
const subTable = tableGenerator . newOutputTable ( { head : [ 'Display Type' ] } )
29
37
for ( const item of items ) {
30
38
subTable . push ( [ item . displayType ] )
31
39
}
32
40
return subTable . toString ( )
33
41
}
34
42
35
- function buildLabelDisplayTypeTable ( items : { label : string ; displayType : string } [ ] ) : string {
43
+ const buildLabelDisplayTypeTable = ( items : { label : string ; displayType : string } [ ] ) : string => {
36
44
const subTable = tableGenerator . newOutputTable ( { head : [ 'Label' , 'Display Type' ] } )
37
45
for ( const item of items ) {
38
46
subTable . push ( [ item . label , item . displayType ] )
@@ -81,46 +89,3 @@ export function buildTableOutput(tableGenerator: TableGenerator, presentation: P
81
89
`${ automationConditions } \n\n` +
82
90
automationActions
83
91
}
84
-
85
- export default class PresentationCommand extends APICommand < typeof PresentationCommand . flags > {
86
- static description = 'query device presentation by vid' +
87
- this . apiDocsURL ( 'getDevicePresentation' )
88
-
89
- static flags = {
90
- ...APICommand . flags ,
91
- ...outputItem . flags ,
92
- }
93
-
94
- static args = [
95
- {
96
- name : 'presentationId' ,
97
- description : 'system generated identifier that corresponds to a device presentation' ,
98
- required : true ,
99
- } ,
100
- {
101
- name : 'manufacturerName' ,
102
- description : 'manufacturer name. Defaults to SmartThingsCommunity' ,
103
- required : false ,
104
- } ,
105
- ]
106
-
107
- static examples = [
108
- '$ smartthings presentation fd4adb7f-4a23-4134-9b39-05ed889a03cf' ,
109
- '$ smartthings presentation 4ea31e30-2aba-41c7-a3ec-8f97423d565a SmartThings' ,
110
- '$ smartthings presentation fd4adb7f-4a23-4134-9b39-05ed889a03cf --language=ko' ,
111
- '$ smartthings presentation fd4adb7f-4a23-4134-9b39-05ed889a03cf --language=NONE' ,
112
- '' ,
113
- 'Specifying only the presentationId defaults to the "SmartThingsCommunity" manufacturer' ,
114
- 'name and the language set for the computer\'s operating system. The language can be' ,
115
- 'overridden by specifying an ISO language code. If "NONE" is specified for the language' ,
116
- 'flag then no language header is specified in the API request' ,
117
- ]
118
-
119
- async run ( ) : Promise < void > {
120
- const config = {
121
- buildTableOutput : ( data : PresentationDevicePresentation ) => buildTableOutput ( this . tableGenerator , data ) ,
122
- }
123
- await outputItem ( this , config ,
124
- ( ) => this . client . presentation . getPresentation ( this . args . presentationId , this . args . manufacturerName ) )
125
- }
126
- }
0 commit comments