mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-26 16:35:38 +00:00
29 lines
654 B
Go
29 lines
654 B
Go
package cmd
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/mikefarah/yq/v4/pkg/yqlib"
|
|
)
|
|
|
|
func configurePrinterWriter(format yqlib.PrinterOutputFormat, out io.Writer) yqlib.PrinterWriter {
|
|
|
|
var printerWriter yqlib.PrinterWriter
|
|
|
|
if splitFileExp == "i" {
|
|
colorsEnabled = forceColor
|
|
printerWriter = yqlib.NewMultiPrinterWriter(nil, format)
|
|
|
|
} else if splitFileExp != "" {
|
|
colorsEnabled = forceColor
|
|
splitExp, err := yqlib.NewExpressionParser().ParseExpression(splitFileExp)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
printerWriter = yqlib.NewMultiPrinterWriter(splitExp, format)
|
|
} else {
|
|
printerWriter = yqlib.NewSinglePrinterWriter(out)
|
|
}
|
|
return printerWriter
|
|
}
|