Skip to content

Commit 3413f77

Browse files
committed
internal/filetypes: rename top level "tags" field
When reviewing this code, I was struck by the ambiguity between the top level `tags` field and the `build.File.Tags` field (also encoded as a `tags` field in CUE), and it wasn't immediately obvious that the top level `tags` field didn't play a role in the latter. It doesn't, so make that clearer by renaming it to something that's clearly distinct. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I7356d940634dfd05a40295e62c937e60f2874b5a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200761 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 2662ebe commit 3413f77

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

internal/filetypes/filetypes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func parseType(scope string, mode Mode) (modeVal, fileVal cue.Value, _ error) {
320320
if ok {
321321
fileVal = fileVal.FillPath(cue.MakePath(cue.Str("tags"), cue.Str(tagName)), tagVal)
322322
} else {
323-
info := typesValue.LookupPath(cue.MakePath(cue.Str("tags"), cue.Str(tag)))
323+
info := typesValue.LookupPath(cue.MakePath(cue.Str("tagInfo"), cue.Str(tag)))
324324
if !info.Exists() {
325325
return cue.Value{}, cue.Value{}, errors.Newf(token.NoPos, "unknown filetype %s", tag)
326326
}

internal/filetypes/types.cue

+18-17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package build
2626
encoding!: #Encoding
2727
interpretation?: #Interpretation
2828
form?: #Form
29+
// Note: tags includes values for non-boolean tags only.
2930
tags?: [string]: string
3031
}
3132

@@ -162,23 +163,23 @@ modes: [string]: {
162163
// extensions maps a file extension to its associated default file properties.
163164
extensions: {
164165
// "": _
165-
".cue": tags.cue
166-
".json": tags.json
167-
".jsonl": tags.jsonl
168-
".ldjson": tags.jsonl
169-
".ndjson": tags.jsonl
170-
".yaml": tags.yaml
171-
".yml": tags.yaml
172-
".toml": tags.toml
173-
".txt": tags.text
174-
".go": tags.go
175-
".wasm": tags.binary
176-
".proto": tags.proto
177-
".textproto": tags.textproto
178-
".textpb": tags.textproto // perhaps also pbtxt
166+
".cue": tagInfo.cue
167+
".json": tagInfo.json
168+
".jsonl": tagInfo.jsonl
169+
".ldjson": tagInfo.jsonl
170+
".ndjson": tagInfo.jsonl
171+
".yaml": tagInfo.yaml
172+
".yml": tagInfo.yaml
173+
".toml": tagInfo.toml
174+
".txt": tagInfo.text
175+
".go": tagInfo.go
176+
".wasm": tagInfo.binary
177+
".proto": tagInfo.proto
178+
".textproto": tagInfo.textproto
179+
".textpb": tagInfo.textproto // perhaps also pbtxt
179180

180181
// TODO: jsonseq,
181-
// ".pb": tags.binpb // binarypb
182+
// ".pb": tagInfo.binpb // binarypb
182183
}
183184

184185
// encodings: "": error("no encoding specified")
@@ -327,8 +328,8 @@ interpretations: pb: {
327328
stream: true
328329
}
329330

330-
// tags maps command line tags to file properties.
331-
tags: {
331+
// tagInfo maps command line tags to file properties.
332+
tagInfo: {
332333
schema: form: "schema"
333334
graph: form: "graph"
334335
dag: form: "dag"

0 commit comments

Comments
 (0)