@@ -14,9 +14,10 @@ import { stripIndent } from 'common-tags';
1414import startCase from 'lodash.startcase' ;
1515import logSymbols from 'log-symbols' ;
1616import title from 'title' ;
17+ import { OutputFormat } from '../commands/shared' ;
1718import { ListConfig } from '../config/list' ;
1819import { logger } from '../utils/logger' ;
19- import { writeOutput } from '../utils/output' ;
20+ import { writeJSONOutput , writeOutput } from '../utils/output' ;
2021import { redactPartOfString , shouldPrettyPrint , windowSize } from './utils' ;
2122
2223type KeyMaps = {
@@ -292,7 +293,7 @@ function prettyPrintSection<T extends ListOptions>(
292293function printListResultTerminal ( result : ListResult , config : ListConfig ) : void {
293294 const sections = Object . keys ( result ) as ListOptions [ ] ;
294295 const output = sections
295- . map ( section => prettyPrintSection ( section , result [ section ] ) )
296+ . map ( ( section ) => prettyPrintSection ( section , result [ section ] ) )
296297 . join ( `\n\n${ chalk . dim ( LONG_LINE ) } \n\n` ) ;
297298
298299 let metaInfo = stripIndent ( chalk `
@@ -301,8 +302,9 @@ function printListResultTerminal(result: ListResult, config: ListConfig): void {
301302 ` ) ;
302303
303304 if ( config . serviceSid || config . serviceName ) {
304- metaInfo += chalk `\n{cyan.bold Service} ${ config . serviceSid ||
305- config . serviceName } `;
305+ metaInfo += chalk `\n{cyan.bold Service} ${
306+ config . serviceSid || config . serviceName
307+ } `;
306308 }
307309
308310 if ( config . environment ) {
@@ -313,7 +315,15 @@ function printListResultTerminal(result: ListResult, config: ListConfig): void {
313315 writeOutput ( output ) ;
314316}
315317
316- export function printListResult ( result : ListResult , config : ListConfig ) : void {
318+ export function printListResult (
319+ result : ListResult ,
320+ config : ListConfig ,
321+ outputFormat : OutputFormat
322+ ) : void {
323+ if ( outputFormat === 'json' ) {
324+ writeJSONOutput ( result ) ;
325+ return ;
326+ }
317327 if ( shouldPrettyPrint && ! config . properties && ! config . extendedOutput ) {
318328 printListResultTerminal ( result , config ) ;
319329 } else {
0 commit comments