mirror of
https://github.com/mikefarah/yq.git
synced 2026-06-26 23:17:43 +00:00
When using --split-exp to split documents into per-file outputs, yq silently overwrites any pre-existing files at the target paths because os.Create truncates. For workflows that generate filenames from input data (e.g. '.metadata.name + ".yml"'), this can clobber unrelated files when two documents map to the same name, or when a target path collides with something already on disk. This change adds an opt-in --split-exp-no-overwrite flag (and a matching yqlib constructor NewMultiPrinterWriterWithOptions) that uses O_WRONLY|O_CREATE|O_EXCL so existing files are left untouched and yq exits with a clear error message instead. The default behaviour (overwrite) is unchanged; the original NewMultiPrinterWriter constructor still exists and now delegates to the new options-aware constructor with noOverwrite=false. Fixes #2028
41 lines
694 B
Go
41 lines
694 B
Go
package cmd
|
|
|
|
var unwrapScalarFlag = newUnwrapFlag()
|
|
|
|
var printNodeInfo = false
|
|
|
|
var unwrapScalar = false
|
|
|
|
var writeInplace = false
|
|
var outputToJSON = false
|
|
|
|
var outputFormat = ""
|
|
|
|
var inputFormat = ""
|
|
|
|
var exitStatus = false
|
|
var indent = 2
|
|
var noDocSeparators = false
|
|
var nullInput = false
|
|
var nulSepOutput = false
|
|
var verbose = false
|
|
var version = false
|
|
var prettyPrint = false
|
|
|
|
var forceColor = false
|
|
var forceNoColor = false
|
|
var colorsEnabled = false
|
|
|
|
// can be either "" (off), "extract" or "process"
|
|
var frontMatter = ""
|
|
|
|
var splitFileExp = ""
|
|
var splitFileExpFile = ""
|
|
var splitFileNoOverwrite = false
|
|
|
|
var completedSuccessfully = false
|
|
|
|
var forceExpression = ""
|
|
|
|
var expressionFile = ""
|