refactor(builtins): move find/xargs/timeout from interpreter to builtins#759
Open
refactor(builtins): move find/xargs/timeout from interpreter to builtins#759
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
find,xargs, andtimeoutlogic from privateInterpretermethods to properBuiltinimplementationsExecutionPlanenum andexecution_plan()trait method so builtins can request sub-command execution without direct interpreter accessexecute_builtin_plan()method, replacing three special-case dispatch blocksinterpreter/mod.rsDesign
Builtins that need to run sub-commands (timeout, xargs, find -exec) now return an
ExecutionPlandescribing what to execute. The interpreter checks for plans before falling back to normalexecute(). This keeps parsing/validation in builtins while the interpreter handles actual command dispatch.Test plan
cargo test --all-features)cargo clippy --all-targets --all-features -- -D warningscleancargo fmt --checkcleanexecution_plan()on timeout, xargs, and find builtinsCloses #731