internal/encoding: support cue file type

Change-Id: Ic8a0bb00c5db92079f8738a9b7179bd86f7c49f5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5093
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/encoding/encoding.go b/internal/encoding/encoding.go
index 300a3f1..22871ea 100644
--- a/internal/encoding/encoding.go
+++ b/internal/encoding/encoding.go
@@ -25,6 +25,8 @@
 	"cuelang.org/go/cue"
 	"cuelang.org/go/cue/ast"
 	"cuelang.org/go/cue/build"
+	"cuelang.org/go/cue/format"
+	"cuelang.org/go/cue/parser"
 	"cuelang.org/go/encoding/json"
 	"cuelang.org/go/encoding/protobuf"
 	"cuelang.org/go/internal/filetypes"
@@ -101,10 +103,12 @@
 	Stdin  io.Reader
 	Stdout io.Writer
 
-	Force bool // overwrite existing files.
+	Force  bool // overwrite existing files.
+	Stream bool // will potentially write more than one document per file
 
 	EscapeHTML bool
 	ProtoPath  []string
+	Format     []format.Option
 }
 
 // NewDecoder returns a stream of non-rooted data expressions. The encoding
@@ -129,6 +133,9 @@
 
 	path := f.Filename
 	switch f.Encoding {
+	case build.CUE:
+		i.file, i.err = parser.ParseFile(path, r, parser.ParseComments)
+		// TODO: verify input format
 	case build.JSON, build.JSONL:
 		i.next = json.NewDecoder(nil, path, r).Extract
 		i.Next()