(ctx context.Context, args []string)
| 284 | } |
| 285 | |
| 286 | func (h *shellCallHandler) loadInput(ctx context.Context, args []string) (*ShellState, error) { |
| 287 | stdin := interp.HandlerCtx(ctx).Stdin |
| 288 | |
| 289 | // First command in pipeline: e.g., `cmd1 | cmd2 | cmd3` |
| 290 | if stdin == nil { |
| 291 | return nil, nil |
| 292 | } |
| 293 | |
| 294 | b, err := io.ReadAll(stdin) |
| 295 | if err != nil { |
| 296 | return nil, err |
| 297 | } |
| 298 | s := string(b) |
| 299 | |
| 300 | // Stdin expects a single state |
| 301 | st, err := h.state.Load(GetStateKey(s)) |
| 302 | if st == nil && err == nil { |
| 303 | if h.Debug() { |
| 304 | // Need `.debug` to check what was actually passed. Just write |
| 305 | // to stderr instead of logger. |
| 306 | shellDebug(ctx, "unexpected stdin", args, s) |
| 307 | } |
| 308 | return nil, fmt.Errorf("unexpected input for command %q", args[0]) |
| 309 | } |
| 310 | |
| 311 | // Should pass state even if err != nil, for cleanup. |
| 312 | return st, err |
| 313 | } |
| 314 | |
| 315 | // cmd is the main logic for executing simple commands |
| 316 | func (h *shellCallHandler) cmd(ctx context.Context, args []string, st *ShellState) (*ShellState, error) { |
no test coverage detected