Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
tools/trim: move trim logic to package
Browse files Browse the repository at this point in the history
This is by no means a complete API, but is a first pass to hoist
the logic from the cmd directory.

Change-Id: I39059fa05d51bc5f5f5ab628325728f27231ee61
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4201
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Dec 2, 2019
1 parent c8d6c39 commit cba0372
Show file tree
Hide file tree
Showing 3 changed files with 514 additions and 398 deletions.
28 changes: 23 additions & 5 deletions cmd/cue/cmd/testdata/script/trim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ foo: bar: {
_value: "here"
b: "foo"
c: 45
f: ">> here <<" // TODO: remove

sList: [{b: "foo"}, {}]
}
Expand All @@ -40,7 +41,7 @@ foo: multipath: {
t: [string]: {
// Combined with the other constraints, we know the value must be 5 and
// thus the entry below can be eliminated.
x: >=5 & <=8
x: >=5 & <=8 & int
}

t: u: {
Expand Down Expand Up @@ -85,10 +86,23 @@ foo: [string]: {

foo: bar: {
_value: "here"
b: "foo"
c: 45

sList: [{b: "foo"}, {}]
a: 4
b: "foo"
c: 45
e: string
f: ">> here <<" // TODO: remove

// 5 is an integer, so this can be removed.
n: int

struct: {a: 3.0}

list: ["foo", float]

sList: [{a: 8, b: "foo"}, {b: "foo"}]
rList: [{a: string}]
rcList: [{a: "a", c: "foo"}]
}

foo: baz: {}
Expand All @@ -97,10 +111,11 @@ foo: multipath: {
t: [string]: {
// Combined with the other constraints, we know the value must be 5 and
// thus the entry below can be eliminated.
x: >=5 & <=8
x: >=5 & <=8 & int
}

t: u: {
x: 5
}
}

Expand All @@ -111,7 +126,10 @@ group: {
}

comp: bar: {
a: 4
aa: 8 // new value
}

comp: baz: {} // removed: fully implied by comprehension above
}
-- cue.mod --
Loading

0 comments on commit cba0372

Please sign in to comment.