Skip to content

feat(exec): add dry-run mode to CommandExecutor#41

Merged
fohte merged 2 commits intomainfrom
fohte/impl-runok-init-dry-run
Feb 17, 2026
Merged

feat(exec): add dry-run mode to CommandExecutor#41
fohte merged 2 commits intomainfrom
fohte/impl-runok-init-dry-run

Conversation

@fohte
Copy link
Owner

@fohte fohte commented Feb 16, 2026

Why

  • runok exec --dry-run and runok check need to validate command existence and permissions without actually executing the command

What

  • Add dry_run method to the CommandExecutor trait that performs command existence check, permission validation, and execution mode determination, returning a structured DryRunResult

Open with Devin

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>
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 runok exec --dry-run and runok check.

Highlights

  • New Dry-Run Capability: Introduced a dry_run method to the CommandExecutor trait, enabling validation of commands without actual execution.
  • Structured Dry-Run Results: Added a DryRunResult struct to provide detailed information about the outcome of a dry-run, including program name, execution mode, validity, and any errors.
  • Implementation for ProcessCommandExecutor: Provided a concrete implementation of the dry_run method for ProcessCommandExecutor, handling command existence checks, permission validation, and execution mode determination.
  • Comprehensive Testing: Included new rstest cases to thoroughly test the dry_run functionality across various scenarios, including existing/non-existent commands, shell commands, empty inputs, and sandbox policies.
Changelog
  • src/exec/command_executor.rs
    • Defined a new DryRunResult struct to encapsulate dry-run validation outcomes.
    • Added a dry_run method signature to the CommandExecutor trait.
    • Provided an implementation for the dry_run method within ProcessCommandExecutor.
    • Expanded the test suite with new rstest cases specifically for the dry_run method.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot]

This comment was marked as resolved.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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>
@fohte fohte merged commit 77eb8ce into main Feb 17, 2026
3 checks passed
@fohte fohte deleted the fohte/impl-runok-init-dry-run branch February 17, 2026 00:14
@fohte-bot fohte-bot bot mentioned this pull request Feb 17, 2026
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.

1 participant