github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/pkg/joom/cuetools/tools.go (about) 1 package cuetools 2 3 import ( 4 "fmt" 5 6 "github.com/joomcode/cue/cue" 7 cueerrors "github.com/joomcode/cue/cue/errors" 8 "github.com/joomcode/cue/cue/format" 9 ) 10 11 func CueErrorDetails(err error) error { 12 return fmt.Errorf(cueerrors.Details(err, nil)) 13 } 14 15 func PrintCueValue(source string, v cue.Value) { 16 astNode := v.Syntax( 17 cue.Final(), 18 cue.Optional(true), 19 cue.Concrete(true), 20 cue.Definitions(false), 21 cue.Hidden(false), 22 cue.Attributes(true), 23 cue.Docs(true), 24 ) 25 jsonValue, err := format.Node(astNode) 26 if err != nil { 27 fmt.Println("Error during AST formatting:", err) 28 return 29 } 30 if source != "" { 31 source = source + ": " 32 } 33 fmt.Printf("%s%s\n", source, string(jsonValue)) 34 }