MCPcopy Index your code
hub / github.com/dagger/dagger / shellDebugLine

Function shellDebugLine

cmd/dagger/shell_debug.go:14–48  ·  view source on GitHub ↗
(title string, data ...any)

Source from the content-addressed store, hash-verified

12)
13
14func shellDebugLine(title string, data ...any) string {
15 lvl := "[DBG]"
16
17 sb := new(strings.Builder)
18 sb.WriteString(termenv.String(lvl).Foreground(termenv.ANSIMagenta).String())
19 sb.WriteString(" ")
20 sb.WriteString(termenv.String(title).Bold().Faint().String())
21
22 extra := new(strings.Builder)
23 if len(data) > 0 {
24 // if first element is a string, display it next to title
25 if s, ok := data[0].(string); ok {
26 extra.WriteString(s)
27 data = data[1:]
28 }
29 // for other values, display each in a new arrowed line
30 iw := indent.NewWriter(uint(len(lvl)+1), nil)
31 for _, arg := range data {
32 if arg != nil {
33 fmt.Fprintf(iw, "\n→ %s", shellDebugFormat(arg))
34 }
35 }
36 extra.WriteString(iw.String())
37 }
38
39 // style everything faint so normal output stands out more
40 if extra.Len() > 0 {
41 sb.WriteString(" ")
42 sb.WriteString(termenv.String(extra.String()).Faint().String())
43 }
44
45 sb.WriteString("\n")
46
47 return sb.String()
48}
49
50func shellDebugFormat(data any) string {
51 switch t := data.(type) {

Callers 1

shellDebugFunction · 0.85

Calls 3

shellDebugFormatFunction · 0.85
StringMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected