Skip to content

Commit 8fb5fea

Browse files
committed
cmd/cue: move CUE_DEBUG_PARSER_TRACE to CUE_DEBUG=parsertrace
This was the last of the old debugging flags with a TODO to consolidate into CUE_DEBUG. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I77a5b503c912a9ce383a055b5bfd246a4e0e1ea8 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214763 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent a95cfa8 commit 8fb5fea

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

cmd/cue/cmd/common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"cuelang.org/go/cue/parser"
3333
"cuelang.org/go/cue/token"
3434
"cuelang.org/go/internal"
35+
"cuelang.org/go/internal/cuedebug"
3536
"cuelang.org/go/internal/encoding"
3637
"cuelang.org/go/internal/filetypes"
3738
)
@@ -57,8 +58,8 @@ func defaultConfig() (*config, error) {
5758
parser.FromVersion(version),
5859
parser.ParseComments,
5960
}
60-
// TODO: consolidate all options into a single CUE_DEBUG variable.
61-
if os.Getenv("CUE_DEBUG_PARSER_TRACE") != "" {
61+
cuedebug.Init()
62+
if cuedebug.Flags.ParserTrace {
6263
options = append(options, parser.Trace)
6364
}
6465
return parser.ParseFile(name, src, options...)

cmd/cue/cmd/help.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ If an environment variable is unset or empty, sensible default setting is used.
317317
Force fields in stucts to be sorted lexicographically.
318318
toolsflow
319319
Print task dependency mermaid graphs in 'cue cmd'.
320+
parsertrace
321+
Print a trace of parsed CUE productions.
320322
321323
CUE_EXPERIMENT and CUE_DEBUG are comma-separated lists of key-value strings,
322324
where the value is a boolean "true" or "1" if omitted. For example:

cmd/cue/cmd/testdata/script/parser_trace.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
env CUE_DEBUG_PARSER_TRACE=1
1+
env CUE_DEBUG=parsertrace=1
22

33
exec cue vet -c=false schema.cue
44
cmp stdout parser-trace.stdout

internal/cuedebug/cuedebug.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type Config struct {
4747

4848
// ToolsFlow causes [cuelang.org/go/tools/flow] to print a task dependency mermaid graph.
4949
ToolsFlow bool
50+
51+
// ParserTrace causes [cuelang.org/go/cue/parser] to print a trace of parsed productions.
52+
ParserTrace bool
5053
}
5154

5255
// Init initializes Flags. Note: this isn't named "init" because we

0 commit comments

Comments
 (0)