Skip to content

Commit bc0d56a

Browse files
authored
Text makes sense as the default cli output format, we should only try and be smart about the cli output format if we're confident it's being run by an agnent (#278)
1 parent 6e462d0 commit bc0d56a

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func init() {
239239

240240
rootCmd.Version = cfg.Version
241241
rootCmd.CompletionOptions.DisableDefaultCmd = true
242-
rootCmd.PersistentFlags().StringP("output", "o", "interactive", "interactive, json, yaml, or text (auto: json in non-TTY contexts)")
242+
rootCmd.PersistentFlags().StringP("output", "o", "interactive", "interactive, json, yaml, or text (auto: text in non-TTY contexts)")
243243
rootCmd.PersistentFlags().Bool(command.ConfirmFlag, false, "set to skip confirmation prompts")
244244

245245
// Flags from the old CLI that we error with a helpful message

cmd/root_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestRootPersistentPreRunOutputResolution(t *testing.T) {
2020
wantStackContext bool
2121
}{
2222
{
23-
name: "default output with unchanged flag uses auto mode and resolves json for non-tty",
23+
name: "default output with unchanged flag uses auto mode and resolves text for non-tty",
2424
input: runRootPersistentPreRunInput{
2525
explicitOutput: false,
2626
outputValue: "interactive",
@@ -30,7 +30,7 @@ func TestRootPersistentPreRunOutputResolution(t *testing.T) {
3030
StderrTTY: true,
3131
},
3232
},
33-
wantOutput: command.JSON,
33+
wantOutput: command.TEXT,
3434
},
3535
{
3636
name: "explicit interactive remains interactive regardless of non-tty ci signals",
@@ -104,7 +104,7 @@ func TestRootPersistentPreRunOutputResolution(t *testing.T) {
104104
wantOutput: command.YAML,
105105
},
106106
{
107-
name: "ci truthy in auto mode resolves json",
107+
name: "ci truthy in auto mode resolves text",
108108
input: runRootPersistentPreRunInput{
109109
explicitOutput: false,
110110
outputValue: "interactive",
@@ -115,7 +115,7 @@ func TestRootPersistentPreRunOutputResolution(t *testing.T) {
115115
CI: true,
116116
},
117117
},
118-
wantOutput: command.JSON,
118+
wantOutput: command.TEXT,
119119
},
120120
{
121121
name: "all tty and ci false in auto mode resolves interactive",

pkg/command/outputresolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func ResolveAutoOutput(explicitOutputSet bool, requested Output, signals Runtime
6060
return Interactive, nil
6161
}
6262

63-
return JSON, nil
63+
return TEXT, nil
6464
}
6565

6666
func isSupportedOutput(output Output) bool {

pkg/command/outputresolver_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func TestResolveAutoOutput(t *testing.T) {
229229
StdoutTTY: true,
230230
StderrTTY: true,
231231
},
232-
wantOutput: command.JSON,
232+
wantOutput: command.TEXT,
233233
},
234234
{
235235
name: "all tty and ci false resolves interactive",
@@ -243,40 +243,40 @@ func TestResolveAutoOutput(t *testing.T) {
243243
wantOutput: command.Interactive,
244244
},
245245
{
246-
name: "non-tty stdin resolves json",
246+
name: "non-tty stdin resolves text",
247247
explicitOutput: false,
248248
requestedOutput: command.Interactive,
249249
signals: command.RuntimeSignals{
250250
StdinTTY: false,
251251
StdoutTTY: true,
252252
StderrTTY: true,
253253
},
254-
wantOutput: command.JSON,
254+
wantOutput: command.TEXT,
255255
},
256256
{
257-
name: "non-tty stdout resolves json",
257+
name: "non-tty stdout resolves text",
258258
explicitOutput: false,
259259
requestedOutput: command.Interactive,
260260
signals: command.RuntimeSignals{
261261
StdinTTY: true,
262262
StdoutTTY: false,
263263
StderrTTY: true,
264264
},
265-
wantOutput: command.JSON,
265+
wantOutput: command.TEXT,
266266
},
267267
{
268-
name: "non-tty stderr resolves json",
268+
name: "non-tty stderr resolves text",
269269
explicitOutput: false,
270270
requestedOutput: command.Interactive,
271271
signals: command.RuntimeSignals{
272272
StdinTTY: true,
273273
StdoutTTY: true,
274274
StderrTTY: false,
275275
},
276-
wantOutput: command.JSON,
276+
wantOutput: command.TEXT,
277277
},
278278
{
279-
name: "ci true resolves json",
279+
name: "ci true resolves text",
280280
explicitOutput: false,
281281
requestedOutput: command.Interactive,
282282
signals: command.RuntimeSignals{
@@ -285,10 +285,10 @@ func TestResolveAutoOutput(t *testing.T) {
285285
StderrTTY: true,
286286
CI: true,
287287
},
288-
wantOutput: command.JSON,
288+
wantOutput: command.TEXT,
289289
},
290290
{
291-
name: "TERM=dumb resolves json even with all TTYs",
291+
name: "TERM=dumb resolves text even with all TTYs",
292292
explicitOutput: false,
293293
requestedOutput: command.Interactive,
294294
signals: command.RuntimeSignals{
@@ -297,7 +297,7 @@ func TestResolveAutoOutput(t *testing.T) {
297297
StderrTTY: true,
298298
DumbTerminal: true,
299299
},
300-
wantOutput: command.JSON,
300+
wantOutput: command.TEXT,
301301
},
302302
{
303303
name: "invalid requested output returns error",

0 commit comments

Comments
 (0)