Skip to content

Commit fab9858

Browse files
committed
feat: Add defaulting to plain reporter if tty is not available
1 parent 6c84899 commit fab9858

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/common/base-command.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CommandRequestData, PressKeyToContinueRequestData } from '@codifycli/sc
55
import createDebug from 'debug';
66

77
import { LoginHelper } from '../connect/login-helper.js';
8-
import { Event, ctx } from '../events/context.js';
8+
import { ctx, Event } from '../events/context.js';
99
import { LoginOrchestrator } from '../orchestrators/login.js';
1010
import { Reporter, ReporterFactory, ReporterType } from '../ui/reporters/reporter.js';
1111
import { 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

Comments
 (0)