| 215 | } |
| 216 | |
| 217 | func spreadDebugArgs(args ...any) []any { |
| 218 | a := []any{} |
| 219 | for _, arg := range args { |
| 220 | switch t := arg.(type) { |
| 221 | case *ShellState: |
| 222 | if t == nil { |
| 223 | a = append(a, "state", nil) |
| 224 | continue |
| 225 | } |
| 226 | a = append(a, "key", t.Key) |
| 227 | if t.ModDigest != "" { |
| 228 | a = append(a, "module", t.ModDigest) |
| 229 | } |
| 230 | if t.Cmd != "" { |
| 231 | a = append(a, "namespace", t.Cmd) |
| 232 | } |
| 233 | if len(t.Calls) > 0 { |
| 234 | a = append(a, "calls", t.Calls) |
| 235 | } |
| 236 | if t.Error != nil { |
| 237 | a = append(a, "error", t.Error) |
| 238 | } |
| 239 | default: |
| 240 | a = append(a, arg) |
| 241 | } |
| 242 | } |
| 243 | return a |
| 244 | } |
| 245 | |
| 246 | // ShellState is an intermediate representation of a query |
| 247 | // |