Skip to content

refactor(builtins): move find/xargs/timeout from interpreter to builtins#759

Open
chaliy wants to merge 2 commits intomainfrom
claude/issue-731-ZDBNW
Open

refactor(builtins): move find/xargs/timeout from interpreter to builtins#759
chaliy wants to merge 2 commits intomainfrom
claude/issue-731-ZDBNW

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 18, 2026

Summary

  • Move ~830 lines of find, xargs, and timeout logic from private Interpreter methods to proper Builtin implementations
  • Add ExecutionPlan enum and execution_plan() trait method so builtins can request sub-command execution without direct interpreter access
  • Interpreter fulfills plans via a single generic execute_builtin_plan() method, replacing three special-case dispatch blocks
  • Net reduction of ~326 lines from interpreter/mod.rs

Design

Builtins that need to run sub-commands (timeout, xargs, find -exec) now return an ExecutionPlan describing what to execute. The interpreter checks for plans before falling back to normal execute(). This keeps parsing/validation in builtins while the interpreter handles actual command dispatch.

ExecutionPlan::Timeout { duration, command }  → tokio::time::timeout wrapping execute_command
ExecutionPlan::Batch { commands }             → sequential execute_command for each SubCommand

Test plan

  • All 3,278+ existing tests pass (cargo test --all-features)
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo fmt --check clean
  • New unit tests for execution_plan() on timeout, xargs, and find builtins
  • Integration tests for timeout/xargs/find continue passing via interpreter

Closes #731

chaliy added 2 commits March 18, 2026 16:57
Move ~830 lines of find, xargs, and timeout logic from private
Interpreter methods to proper Builtin implementations with an
ExecutionPlan-based interpreter hook for sub-command execution.

- Add ExecutionPlan enum (Timeout, Batch) and SubCommand struct to
  builtins::mod for builtins that need to run sub-commands
- Add execution_plan() method to Builtin trait (default returns None)
- Timeout builtin: full argument parsing + returns ExecutionPlan::Timeout
- Xargs builtin: full argument parsing + returns ExecutionPlan::Batch
- Find builtin: -exec/-execdir support via ExecutionPlan::Batch
- Interpreter: generic execute_builtin_plan() fulfills plans from any
  builtin, replacing three special-case dispatch blocks
- Remove execute_timeout, execute_xargs, execute_find, find_collect,
  find_printf_format, parse_timeout_duration from Interpreter
- Net reduction of ~326 lines

Closes #731
Add missing documentation for the sub-command delegation pattern:
ExecutionPlan enum, SubCommand struct, and the execution_plan() trait
method used by timeout, xargs, and find -exec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: move find/xargs/timeout from interpreter to builtins

1 participant