@@ -115,6 +115,9 @@ func (c *CLI) onStart() {
115115 if c .outputValue != common .OutputValueNone && c .outputValue != common .OutputValueAll {
116116 c .outputFormat = fmtx .Text
117117 }
118+ if c .outputQuery != "" && c .outputFormat == fmtx .Text {
119+ c .outputFormat = fmtx .YML
120+ }
118121
119122 noColor := cv .GetBool ("output.no_color" )
120123 if c .outputFormat != fmtx .Text || c .outputLogMode != cfg .OutputLogConsole {
@@ -299,15 +302,16 @@ func (c *CLI) printOutputDataIndented(writer *textio.PrefixWriter, value any, ke
299302}
300303
301304func (c * CLI ) printOutputMarshaled () {
302- if c .outputValue == common .OutputValueNone {
305+ if c .outputQuery != "" {
306+ c .printOutputMarshaledValue (c .queryOutputResponse ())
303307 return
304308 }
305-
306- if c .outputQuery == "" {
309+ if c .outputValue != common .OutputValueNone {
307310 c .printOutputMarshaledValue (c .outputResponse )
308- return
309311 }
312+ }
310313
314+ func (c * CLI ) queryOutputResponse () any {
311315 // JMESPath bug workaround, see: https://github.com/jmespath/go-jmespath/issues/32)
312316 cloned , err := c .outputResponse .Clone ()
313317 if err != nil {
@@ -317,8 +321,7 @@ func (c *CLI) printOutputMarshaled() {
317321 if err != nil {
318322 log .Fatalf ("cannot perform query '%s' on CLI output data: %s" , c .outputQuery , err )
319323 }
320-
321- c .printOutputMarshaledValue (queried )
324+ return queried
322325}
323326
324327func (c * CLI ) printOutputMarshaledValue (value any ) {
0 commit comments