Skip to content

Commit

Permalink
cmd/cue: fix bug in -o, which would not write files for some commands
Browse files Browse the repository at this point in the history
Fixes #802

Change-Id: I297adad9265f6731ee4847f76bc6e9160606a5f5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9067
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
  • Loading branch information
mpvl committed Mar 21, 2021
1 parent fec7a9c commit 35e19b2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/cue/cmd/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ func runDef(cmd *Command, args []string) error {
exitOnErr(cmd, err, true)
}
exitOnErr(cmd, iter.err(), true)

err = e.Close()
exitOnErr(cmd, err, true)

return nil
}
4 changes: 4 additions & 0 deletions cmd/cue/cmd/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,9 @@ func runEval(cmd *Command, args []string) error {
}
}
exitOnErr(cmd, iter.err(), true)

err = e.Close()
exitOnErr(cmd, err, true)

return nil
}
30 changes: 30 additions & 0 deletions cmd/cue/cmd/testdata/script/def_openapi.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
cue def foo.cue -o openapi+cue:out.cue
cmp out.cue expect-out.cue

cue def openapi+cue: expect-cue-out -o -

cue def foo.cue -o openapi:-
Expand Down Expand Up @@ -275,3 +278,30 @@ info: {
b: uint & <10
...
}
-- expect-out.cue --
openapi: "3.0.0"
info: {
title: "Some clever title."
version: "v1"
}
paths: {}
components: schemas: {
Bar: {
type: "object"
required: ["foo"]
properties: foo: $ref: "#/components/schemas/Foo"
}
Foo: {
type: "object"
required: ["a", "b"]
properties: {
a: type: "integer"
b: {
type: "integer"
minimum: 0
maximum: 10
exclusiveMaximum: true
}
}
}
}
6 changes: 6 additions & 0 deletions cmd/cue/cmd/testdata/script/eval_newline.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
cue eval ./data.cue
cmp stdout expect-stdout

cue eval ./data.cue -o out.cue
cmp out.cue expect-out.cue

-- data.cue --
3
-- expect-stdout --
3
-- expect-out.cue --
3

0 comments on commit 35e19b2

Please sign in to comment.