mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
* feat: Add UnwrapScalar to ShellVariablesPreferences - Add UnwrapScalar boolean field to ShellVariablesPreferences struct. - Initialize UnwrapScalar to false in NewDefaultShellVariablesPreferences. - This preference will control whether shell output should be quoted or raw. * feat: Propagate unwrapScalar to ShellVariablesPreferences - In configureEncoder function, set UnwrapScalar in ConfiguredShellVariablesPreferences. - This ensures the -r flag's state is passed to the shell encoder for raw output control. * feat: Implement conditional quoting in shellVariablesEncoder - Modify doEncode method to check pe.prefs.UnwrapScalar. - If UnwrapScalar is true, output raw node.Value. - Otherwise, use quoteValue for shell-safe quoting. - This enables quote-free output for Kubernetes workflows when -r is used. * test: Add tests for UnwrapScalar in shell encoder - Introduce assertEncodesToUnwrapped helper function. - Add TestShellVariablesEncoderUnwrapScalar to verify quote-free output with -r. - Add TestShellVariablesEncoderDefaultQuoting to confirm default quoting behavior without -r. - Ensure comprehensive testing of conditional quoting logic for shell output. * remove redundant test
16 lines
334 B
Go
16 lines
334 B
Go
package yqlib
|
|
|
|
type ShellVariablesPreferences struct {
|
|
KeySeparator string
|
|
UnwrapScalar bool
|
|
}
|
|
|
|
func NewDefaultShellVariablesPreferences() ShellVariablesPreferences {
|
|
return ShellVariablesPreferences{
|
|
KeySeparator: "_",
|
|
UnwrapScalar: false,
|
|
}
|
|
}
|
|
|
|
var ConfiguredShellVariablesPreferences = NewDefaultShellVariablesPreferences()
|