feat(exec): add dry-run mode to CommandExecutor#41
Conversation
CommandExecutor only supported full execution via exec() or spawn+wait. There was no way to validate a command without actually running it, which is needed for --dry-run support in `runok exec`. Add `DryRunResult` struct and `dry_run` method to the `CommandExecutor` trait. The method checks command existence and permissions via the existing `validate` logic, determines the execution mode, and returns structured results without executing the command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @fohte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the command execution system by integrating a dry-run mode. This allows for pre-execution validation of commands, checking their existence, permissions, and determining the intended execution mode without actually running them. This functionality is essential for features that need to verify command viability and behavior upfront, such as Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Review feedback pointed out that Option<String> for the error field prevents consumers from programmatically distinguishing error types, and that cloning the args vector in the Argv case is unnecessary. Replace Option<String> with Option<DryRunError> enum mirroring ExecError variants (NotFound, PermissionDenied, Io). Use Cow<[String]> to borrow args instead of cloning. Strengthen test assertions to match on specific error variants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Why
runok exec --dry-runandrunok checkneed to validate command existence and permissions without actually executing the commandWhat
dry_runmethod to theCommandExecutortrait that performs command existence check, permission validation, and execution mode determination, returning a structuredDryRunResult