cmd/cue/cmd: bail out from errors earlier
Change-Id: I5f67faf64640b85281b27fb6c0bf343ef42447bd
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5409
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/eval.go b/cmd/cue/cmd/eval.go
index f486ad0..910bd22 100644
--- a/cmd/cue/cmd/eval.go
+++ b/cmd/cue/cmd/eval.go
@@ -88,7 +88,7 @@
func runEval(cmd *Command, args []string) error {
b, err := parseArgs(cmd, args, &config{outMode: filetypes.Eval})
- exitOnErr(cmd, err, false)
+ exitOnErr(cmd, err, true)
syn := []cue.Option{
cue.Final(), // for backwards compatibility
diff --git a/cmd/cue/cmd/fmt.go b/cmd/cue/cmd/fmt.go
index ed9f838..5b92705 100644
--- a/cmd/cue/cmd/fmt.go
+++ b/cmd/cue/cmd/fmt.go
@@ -35,7 +35,7 @@
Tests: true,
Tools: true,
}})
- exitOnErr(cmd, err, false)
+ exitOnErr(cmd, err, true)
opts := []format.Option{}
if flagSimplify.Bool(cmd) {
diff --git a/cmd/cue/cmd/orphans.go b/cmd/cue/cmd/orphans.go
index 8687f8e..394f891 100644
--- a/cmd/cue/cmd/orphans.go
+++ b/cmd/cue/cmd/orphans.go
@@ -84,6 +84,9 @@
continue
}
}
+ if err := d.Err(); err != nil {
+ return false, err
+ }
if perFile {
for i, obj := range objs {
@@ -146,6 +149,9 @@
index := newIndex()
for i, file := range objs {
+ if i == 0 {
+ astutil.CopyMeta(f, file)
+ }
expr, p := toExpr(file)
var pathElems []ast.Label
diff --git a/cmd/cue/cmd/testdata/script/vet_path.txt b/cmd/cue/cmd/testdata/script/vet_path.txt
index de79a96..0893851 100644
--- a/cmd/cue/cmd/testdata/script/vet_path.txt
+++ b/cmd/cue/cmd/testdata/script/vet_path.txt
@@ -1,15 +1,18 @@
! cue vet -l 'strings.ToLower(kind)' -l name services.jsonl services.cue
cmp stderr expect-stderr
-- expect-stderr --
-deployment.Booster.name: invalid value "Booster" (excluded by !~"[A-Z]*"):
+deployment.Booster.name: invalid value "Booster" (excluded by !~"^[A-Z]"):
./services.cue:1:29
./services.jsonl:3:13
-service.booster.name: invalid value "booster" (excluded by !~"[A-Z]*"):
+service."""
+ Supplement
+ foo
+ """.name: invalid value "Supplement\nfoo" (excluded by !~"^[A-Z]"):
./services.cue:2:26
./services.jsonl:3:13
-- services.cue --
-deployment: [string]: name: !~"[A-Z]*"
-service: [string]: name: !~"[A-Z]*"
+deployment: [string]: name: !~"^[A-Z]"
+service: [string]: name: !~"^[A-Z]"
-- services.jsonl --
{
@@ -23,5 +26,5 @@
}
{
"kind": "Service",
- "name": "supplement\nfoo",
-}
\ No newline at end of file
+ "name": "Supplement\nfoo"
+}