(data any)
| 48 | } |
| 49 | |
| 50 | func 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 | |
| 86 | func shellDebug(ctx context.Context, title string, data ...any) { |
| 87 | msg := shellDebugLine(title, data...) |
no test coverage detected