From 64135a16e110fbb4119502c139e0afd6ca9a0685 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Fri, 17 Apr 2020 11:24:45 +1000 Subject: [PATCH] Use single/double instead of singleQuoted/doubleQuoted --- cmd/new_test.go | 4 ++-- cmd/write_test.go | 4 ++-- pkg/yqlib/value_parser.go | 6 ++++-- pkg/yqlib/value_parser_test.go | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/new_test.go b/cmd/new_test.go index e97d31b5..4c20195f 100644 --- a/cmd/new_test.go +++ b/cmd/new_test.go @@ -54,7 +54,7 @@ func TestNewWithTaggedStyleCmd(t *testing.T) { func TestNewWithDoubleQuotedStyleCmd(t *testing.T) { cmd := getRootCommand() - result := test.RunCmd(cmd, "new b.c cat --style=doubleQuoted") + result := test.RunCmd(cmd, "new b.c cat --style=double") if result.Error != nil { t.Error(result.Error) } @@ -66,7 +66,7 @@ func TestNewWithDoubleQuotedStyleCmd(t *testing.T) { func TestNewWithSingleQuotedStyleCmd(t *testing.T) { cmd := getRootCommand() - result := test.RunCmd(cmd, "new b.c cat --style=singleQuoted") + result := test.RunCmd(cmd, "new b.c cat --style=single") if result.Error != nil { t.Error(result.Error) } diff --git a/cmd/write_test.go b/cmd/write_test.go index c0d65604..db9c4a25 100644 --- a/cmd/write_test.go +++ b/cmd/write_test.go @@ -53,7 +53,7 @@ func TestWriteWithDoubleQuotedStyleCmd(t *testing.T) { defer test.RemoveTempYamlFile(filename) cmd := getRootCommand() - result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=doubleQuoted", filename)) + result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=double", filename)) if result.Error != nil { t.Error(result.Error) } @@ -71,7 +71,7 @@ func TestWriteWithSingleQuotedStyleCmd(t *testing.T) { defer test.RemoveTempYamlFile(filename) cmd := getRootCommand() - result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=singleQuoted", filename)) + result := test.RunCmd(cmd, fmt.Sprintf("write %s b.c cat --style=single", filename)) if result.Error != nil { t.Error(result.Error) } diff --git a/pkg/yqlib/value_parser.go b/pkg/yqlib/value_parser.go index 7df7637e..85a73635 100644 --- a/pkg/yqlib/value_parser.go +++ b/pkg/yqlib/value_parser.go @@ -19,14 +19,16 @@ func (v *valueParser) Parse(argument string, customTag string, customStyle strin var style yaml.Style if customStyle == "tagged" { style = yaml.TaggedStyle - } else if customStyle == "doubleQuoted" { + } else if customStyle == "double" { style = yaml.DoubleQuotedStyle - } else if customStyle == "singleQuoted" { + } else if customStyle == "single" { style = yaml.SingleQuotedStyle } else if customStyle == "literal" { style = yaml.LiteralStyle } else if customStyle == "folded" { style = yaml.FoldedStyle + } else if customStyle != "" { + log.Error("Unknown style %v, ignoring", customStyle) } if argument == "[]" { diff --git a/pkg/yqlib/value_parser_test.go b/pkg/yqlib/value_parser_test.go index 9bc6b22d..a185999b 100644 --- a/pkg/yqlib/value_parser_test.go +++ b/pkg/yqlib/value_parser_test.go @@ -13,8 +13,8 @@ var parseStyleTests = []struct { }{ {"", 0}, {"tagged", yaml.TaggedStyle}, - {"doubleQuoted", yaml.DoubleQuotedStyle}, - {"singleQuoted", yaml.SingleQuotedStyle}, + {"double", yaml.DoubleQuotedStyle}, + {"single", yaml.SingleQuotedStyle}, {"folded", yaml.FoldedStyle}, {"literal", yaml.LiteralStyle}, }