File tree Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
"github.com/spf13/cobra"
21
21
22
22
"cuelang.org/go/cue"
23
+ "cuelang.org/go/cue/build"
23
24
"cuelang.org/go/cue/format"
24
25
"cuelang.org/go/internal"
25
26
"cuelang.org/go/internal/encoding"
@@ -117,19 +118,27 @@ func runEval(cmd *Command, args []string) error {
117
118
}
118
119
v := iter .value ()
119
120
121
+ errHeader := func () {
122
+ if id != "" {
123
+ fmt .Fprintf (cmd .OutOrStderr (), "// %s\n " , id )
124
+ }
125
+ }
126
+ if b .outFile .Encoding != build .CUE {
127
+ err := e .Encode (v )
128
+ if err != nil {
129
+ errHeader ()
130
+ exitOnErr (cmd , err , false )
131
+ }
132
+ continue
133
+ }
134
+
120
135
if flagConcrete .Bool (cmd ) {
121
136
syn = append (syn , cue .Concrete (true ))
122
137
}
123
138
if flagHidden .Bool (cmd ) || flagAll .Bool (cmd ) {
124
139
syn = append (syn , cue .Hidden (true ))
125
140
}
126
141
127
- errHeader := func () {
128
- if id != "" {
129
- fmt .Fprintf (cmd .OutOrStderr (), "// %s\n " , id )
130
- }
131
- }
132
-
133
142
if len (b .expressions ) > 1 {
134
143
b , _ := format .Node (b .expressions [i % len (b .expressions )])
135
144
id = string (b )
Original file line number Diff line number Diff line change
1
+
2
+ # Hidden values are dropped when outputting CUE. This is fine in eval for
3
+ # debugging, but not when the final result needs to be compiled again to be
4
+ # converted to another format.
5
+
6
+ cue eval in.cue --out yaml
7
+ cmp stdout expect-stdout
8
+
9
+ -- in.cue --
10
+ #Foo: {
11
+ a: string
12
+ b: string
13
+ ab: "\(a)\(b)"
14
+ }
15
+
16
+ {
17
+ a: "aaa"
18
+ b: "bbb"
19
+ } & #Foo
20
+
21
+ #Bar: {
22
+ _c: string
23
+ _d: string
24
+ cd: "\(_c)\(_d)"
25
+ }
26
+
27
+ {
28
+ _c: "ccc"
29
+ _d: "ddd"
30
+ } & #Bar
31
+
32
+ -- expect-stdout --
33
+ a: aaa
34
+ b: bbb
35
+ ab: aaabbb
36
+ cd: cccddd
You can’t perform that action at this time.
0 commit comments