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

Function shellDebugFormat

cmd/dagger/shell_debug.go:50–84  ·  view source on GitHub ↗
(data any)

Source from the content-addressed store, hash-verified

48}
49
50func shellDebugFormat(data any) string {
51 switch t := data.(type) {
52 case nil:
53 return ""
54 case string:
55 return t
56 case []byte:
57 return string(t)
58 case error:
59 return fmt.Sprintf("Error: %s", t.Error())
60 case *ShellState:
61 if t == nil {
62 return "State: <nil>"
63 }
64 return shellDebugFormat(*t)
65 case ShellState:
66 if t.IsError() {
67 return shellDebugFormat(t.Error)
68 }
69 r := fmt.Sprintf("[key=%s]", t.Key)
70 if t.ModDigest != "" {
71 r += fmt.Sprintf(" [module=%s]", t.ModDigest)
72 }
73 if t.Cmd != "" {
74 r += fmt.Sprintf(" [namespace=%s]", t.Cmd)
75 }
76 if len(t.Calls) > 0 {
77 r += ":\n" + shellDebugFormat(t.Calls)
78 }
79 return fmt.Sprintf("State %s", r)
80 default:
81 b, _ := json.MarshalIndent(t, "", " ")
82 return string(b)
83 }
84}
85
86func shellDebug(ctx context.Context, title string, data ...any) {
87 msg := shellDebugLine(title, data...)

Callers 1

shellDebugLineFunction · 0.85

Calls 2

ErrorMethod · 0.45
IsErrorMethod · 0.45

Tested by

no test coverage detected