@@ -5,7 +5,7 @@ import { CommandRequestData, PressKeyToContinueRequestData } from '@codifycli/sc
55import createDebug from 'debug' ;
66
77import { LoginHelper } from '../connect/login-helper.js' ;
8- import { Event , ctx } from '../events/context.js' ;
8+ import { ctx , Event } from '../events/context.js' ;
99import { LoginOrchestrator } from '../orchestrators/login.js' ;
1010import { Reporter , ReporterFactory , ReporterType } from '../ui/reporters/reporter.js' ;
1111import { spawnSafe } from '../utils/spawn.js' ;
@@ -18,9 +18,8 @@ export abstract class BaseCommand extends Command {
1818 } ) ,
1919 'output' : Flags . option ( {
2020 char : 'o' ,
21- default : 'default' ,
2221 options : [ 'plain' , 'default' , 'json' ] ,
23- description : 'Control the output format.' ,
22+ description : 'Control the output format. Default to default and plain for non-tty environments. Use json for scripts ' ,
2423 } ) ( ) ,
2524 path : Flags . string ( { char : 'p' , description : 'Path to run Codify from.' } ) ,
2625 }
@@ -41,7 +40,7 @@ export abstract class BaseCommand extends Command {
4140 createDebug . enable ( '*' ) ;
4241 }
4342
44- const reporterType = this . getReporterType ( flags ) ;
43+ const reporterType = this . getReporterType ( flags )
4544 this . reporter = ReporterFactory . create ( reporterType )
4645
4746 if ( flags . secure ) {
@@ -157,6 +156,8 @@ export abstract class BaseCommand extends Command {
157156 }
158157 }
159158
160- return ReporterType . DEFAULT ;
159+ if ( ! process . stdin . isTTY ) console . log ( 'Running in non-TTY shell. Defaulting to plain output.' )
160+
161+ return ! process . stdin . isTTY ? ReporterType . PLAIN : ReporterType . DEFAULT ;
161162 }
162163}
0 commit comments