@@ -115,6 +115,9 @@ func (c *CLI) onStart() {
115
115
if c .outputValue != common .OutputValueNone && c .outputValue != common .OutputValueAll {
116
116
c .outputFormat = fmtx .Text
117
117
}
118
+ if c .outputQuery != "" && c .outputFormat == fmtx .Text {
119
+ c .outputFormat = fmtx .YML
120
+ }
118
121
119
122
noColor := cv .GetBool ("output.no_color" )
120
123
if c .outputFormat != fmtx .Text || c .outputLogMode != cfg .OutputLogConsole {
@@ -299,15 +302,16 @@ func (c *CLI) printOutputDataIndented(writer *textio.PrefixWriter, value any, ke
299
302
}
300
303
301
304
func (c * CLI ) printOutputMarshaled () {
302
- if c .outputValue == common .OutputValueNone {
305
+ if c .outputQuery != "" {
306
+ c .printOutputMarshaledValue (c .queryOutputResponse ())
303
307
return
304
308
}
305
-
306
- if c .outputQuery == "" {
309
+ if c .outputValue != common .OutputValueNone {
307
310
c .printOutputMarshaledValue (c .outputResponse )
308
- return
309
311
}
312
+ }
310
313
314
+ func (c * CLI ) queryOutputResponse () any {
311
315
// JMESPath bug workaround, see: https://github.com/jmespath/go-jmespath/issues/32)
312
316
cloned , err := c .outputResponse .Clone ()
313
317
if err != nil {
@@ -317,8 +321,7 @@ func (c *CLI) printOutputMarshaled() {
317
321
if err != nil {
318
322
log .Fatalf ("cannot perform query '%s' on CLI output data: %s" , c .outputQuery , err )
319
323
}
320
-
321
- c .printOutputMarshaledValue (queried )
324
+ return queried
322
325
}
323
326
324
327
func (c * CLI ) printOutputMarshaledValue (value any ) {
0 commit comments