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

Function listTableFormatter

src/lib/command/output.ts:61–71  ·  view source on GitHub ↗
(tableGenerator: TableGenerator, fieldDefinitions: TableFieldDefinition<T>[], includeIndex = false)

Source from the content-addressed store, hash-verified

59 (item: T) => tableGenerator.buildTableFromItem(item, fieldDefinitions)
60
61export const listTableFormatter = <T extends object>(tableGenerator: TableGenerator, fieldDefinitions: TableFieldDefinition<T>[], includeIndex = false): OutputFormatter<T[]> => {
62 let count = 0
63 const tfd = includeIndex ? [{
64 label: '#',
65 value: () => (++count).toString(),
66 }, ...fieldDefinitions] : fieldDefinitions
67 return (data: T[]) => {
68 count = 0
69 return tableGenerator.buildTableFromList(data, tfd)
70 }
71}
72
73export const writeOutput = async (dataStr: string, filename?: string): Promise<void> => {
74 if (filename) {

Callers 2

formatAndWriteListFunction · 0.85
output.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected