cmd/cue/cmd: fix regression that allowed space-separated fields again
Change-Id: I99e9343c2b227c77a525224c2adc875b4c7e3607
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5643
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/encoding/encoding.go b/internal/encoding/encoding.go
index 6618a02..0a0b07c 100644
--- a/internal/encoding/encoding.go
+++ b/internal/encoding/encoding.go
@@ -134,6 +134,7 @@
EscapeHTML bool
ProtoPath []string
Format []format.Option
+ ParseFile func(name string, src interface{}) (*ast.File, error)
}
// NewDecoder returns a stream of non-rooted data expressions. The encoding
@@ -190,7 +191,11 @@
path := f.Filename
switch f.Encoding {
case build.CUE:
- i.file, i.err = parser.ParseFile(path, r, parser.ParseComments)
+ if cfg.ParseFile == nil {
+ i.file, i.err = parser.ParseFile(path, r, parser.ParseComments)
+ } else {
+ i.file, i.err = cfg.ParseFile(path, r)
+ }
i.validate(i.file, f)
case build.JSON, build.JSONL:
i.next = json.NewDecoder(nil, path, r).Extract