Skip to content

refactor: remove parse_command round-trip from type builtin#59

Open
cdprice02 wants to merge 2 commits intomainfrom
refactor/issue-12-type-command
Open

refactor: remove parse_command round-trip from type builtin#59
cdprice02 wants to merge 2 commits intomainfrom
refactor/issue-12-type-command

Conversation

@cdprice02
Copy link
Copy Markdown
Owner

Description

Closes #12.

Replaces the parse_command() round-trip in execute_type() with a direct lookup that checks builtin names then searches PATH, without constructing a full Command. Resolves the TODO at the relevant line in src/executor.rs.

Type of change

  • Refactor

Test checklist

  • cargo test passes
  • cargo clippy --all-targets --all-features -- -D warnings passes

Adds resolve_command_type() in executor.rs that checks BuiltInName directly then searches PATH, without constructing a full Command. Removes From<&Arg> for Command from arg.rs as it was only used by execute_type(). Resolves the TODO in execute_type().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 8, 2026 02:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the type builtin execution path to avoid converting an Arg back into a full Command via parse_command(), aiming to decouple type from parser internals.

Changes:

  • Added a resolve_command_type() helper to classify names as builtin / executable / not found.
  • Updated execute_type() to use direct lookup rather than Command::from(&Arg).
  • Removed impl From<&Arg> for Command from src/arg.rs to eliminate the parse round-trip dependency.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/executor.rs Adds direct command-kind resolution and updates type builtin execution to use it.
src/arg.rs Removes the Arg -> Command conversion that previously invoked parse_command().

…e test

- Replace get_path_files() scan with targeted dir.join(name) lookup in
  resolve_command_type(), avoiding construction of ExecutableCommand for
  every file in PATH
- Expose get_path_dirs() as pub(crate) to support the above
- Add test_execute_type_executable unit test covering the executable branch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 type command to avoid full parse round-trip

2 participants