Skip to content

Commit 38b8955

Browse files
committed
tools/flow: move CUE_DEBUG_TOOLS_FLOW=1 to CUE_DEBUG=toolsflow=1
With the rest of the debugging flags, for consistency. Fixes #3052. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I9092741081db6322f65461dbf742cde809a13aa5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214723 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent 3be8e48 commit 38b8955

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

cmd/cue/cmd/help.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ If an environment variable is unset or empty, sensible default setting is used.
315315
when interacting with module registries.
316316
sortfields
317317
Force fields in stucts to be sorted lexicographically.
318+
toolsflow
319+
Print task dependency mermaid graphs in 'cue cmd'.
318320
319321
CUE_EXPERIMENT and CUE_DEBUG are comma-separated lists of key-value strings,
320322
where the value is a boolean "true" or "1" if omitted. For example:

cmd/cue/cmd/testdata/script/cmd_debug.txtar

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

33
exec cue cmd bar
44
cmp stderr stderr.golden

internal/cuedebug/cuedebug.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
// Flags holds the set of global CUE_DEBUG flags. It is initialized by Init.
1010
var Flags Config
1111

12-
// Flags holds the set of known CUE_DEBUG flags.
12+
// Config holds the set of known CUE_DEBUG flags.
1313
//
1414
// When adding, deleting, or modifying entries below,
1515
// update cmd/cue/cmd/help.go as well for `cue help environment`.
@@ -44,6 +44,9 @@ type Config struct {
4444

4545
// OpenDef disables the check for closedness of definitions.
4646
OpenDef bool
47+
48+
// ToolsFlow causes [cuelang.org/go/tools/flow] to print a task dependency mermaid graph.
49+
ToolsFlow bool
4750
}
4851

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

tools/flow/flow.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ package flow
6969
import (
7070
"context"
7171
"fmt"
72-
"os"
7372
"strings"
7473
"sync/atomic"
7574

@@ -89,9 +88,6 @@ var (
8988

9089
// TODO: ErrUpdate: update and run a dependency, but don't complete a
9190
// dependency as more results may come. This is useful in server mode.
92-
93-
// TODO: move CUE_DEBUG_TOOLS_FLOW=1 to e.g. CUE_DEBUG=toolsflow
94-
debug = os.Getenv("CUE_DEBUG_TOOLS_FLOW") != ""
9591
)
9692

9793
// A TaskFunc creates a Runner for v if v defines a task or reports nil

tools/flow/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"cuelang.org/go/cue/errors"
3434
"cuelang.org/go/internal/core/adt"
3535
"cuelang.org/go/internal/core/eval"
36+
"cuelang.org/go/internal/cuedebug"
3637
"cuelang.org/go/internal/value"
3738
)
3839

@@ -145,7 +146,8 @@ func (c *Controller) markReady(t *Task) {
145146
}
146147
}
147148

148-
if debug {
149+
cuedebug.Init()
150+
if cuedebug.Flags.ToolsFlow {
149151
fmt.Fprintln(os.Stderr, "tools/flow task dependency graph:")
150152
fmt.Fprintln(os.Stderr, "```mermaid")
151153
fmt.Fprint(os.Stderr, mermaidGraph(c))

0 commit comments

Comments
 (0)