cuelang.org/go@v0.13.0/internal/cuedebug/cuedebug.go (about) 1 package cuedebug 2 3 import ( 4 "sync" 5 6 "cuelang.org/go/internal/envflag" 7 ) 8 9 // Flags holds the set of global CUE_DEBUG flags. It is initialized by Init. 10 var Flags Config 11 12 // Config holds the set of known CUE_DEBUG flags. 13 // 14 // When adding, deleting, or modifying entries below, 15 // update cmd/cue/cmd/help.go as well for `cue help environment`. 16 type Config struct { 17 // HTTP enables JSON logging per HTTP request and response made 18 // when interacting with module registries. 19 HTTP bool 20 21 // TODO: consider moving these evaluator-related options into a separate 22 // struct, so that it can be used in an API. We should use embedding, 23 // or some other mechanism, in that case to allow for the full set of 24 // allowed environment variables to be known. 25 26 // Strict sets whether extra aggressive checking should be done. 27 // This should typically default to true for pre-releases and default to 28 // false otherwise. 29 Strict bool 30 31 // LogEval sets the log level for the evaluator. 32 // There are currently only two levels: 33 // 34 // 0: no logging 35 // 1: logging 36 LogEval int 37 38 // Sharing enables structure sharing. 39 Sharing bool `envflag:"default:true"` 40 41 // SortFields forces fields in a struct to be sorted 42 // lexicographically. 43 SortFields bool 44 45 // OpenDef disables the check for closedness of definitions. 46 OpenDef bool 47 48 // ToolsFlow causes [cuelang.org/go/tools/flow] to print a task dependency mermaid graph. 49 ToolsFlow bool 50 51 // ParserTrace causes [cuelang.org/go/cue/parser] to print a trace of parsed productions. 52 ParserTrace bool 53 } 54 55 // Init initializes Flags. Note: this isn't named "init" because we 56 // don't always want it to be called (for example we don't want it to be 57 // called when running "cue help"), and also because we want the failure 58 // mode to be one of error not panic, which would be the only option if 59 // it was a top level init function. 60 func Init() error { 61 return initOnce() 62 } 63 64 var initOnce = sync.OnceValue(func() error { 65 return envflag.Init(&Flags, "CUE_DEBUG") 66 })