Skip to content

fix(command): Action options run the middlewares - #135

Merged
christerswahn merged 1 commit into
mainfrom
new-command-runner
Nov 17, 2026
Merged

christerswahn merged 1 commit into
mainfrom
new-command-runner

Conversation

@christerswahn

@christerswahn christerswahn commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Action options such as --version now run instead of the selected command, with applicable middleware applied to the action result.
  • Bug Fixes
    • Help requests now run runner middleware, including help requested after a nested subcommand. Actions on nested commands stop command traversal at the command where the action option is defined.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CommandRunner now checks for action options before descending to nested commands. When specified, the action runs through the middleware of the command that defines it, and the command chain stops. Tests cover action options at runner, branch, and leaf levels, and update middleware expectations for help requests.

Changes: Action option middleware

Layer / File(s) Summary
Action option dispatch
packages/config/lib/src/command/command_runner.dart
_runNested checks for a specified action option before descending. It runs the action through the defining command’s middleware and stops the chain. Documentation describes action options and limits the documented help behavior to --help and -h.
Middleware behavior tests
packages/config/test/command/command_middleware_test.dart, packages/config/test/command/help_command_test.dart
Tests cover runner-, branch-, and leaf-level action options, including middleware-wrapped results and skipped commands. Help tests now expect runner middleware in the trace.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CommandRunner
  participant CommandMiddleware
  participant ActionOption
  participant NestedCommand
  CommandRunner->>CommandMiddleware: Run action through defining command middleware
  CommandMiddleware->>ActionOption: Invoke action
  ActionOption-->>CommandMiddleware: Return action result
  CommandMiddleware-->>CommandRunner: Return middleware-wrapped result
  Note over CommandRunner,NestedCommand: Nested command does not run when an action option is specified
Loading

Possibly related PRs

  • serverpod/cli_tools#134: Introduces the CommandRunner framework, including middleware and action handling that this change updates.

Suggested reviewers: nielsenko

Merge Risk: Minimal · up to 37193

Action options such as --version now run through the middleware of the command that defines them, and the command chain stops there. Help requests now also run runner middleware. Tests cover the new behavior, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says action options run the middlewares. The change makes _runNested check for a specified action option, run it through the defining command's middleware, and stop the chain there. Tests …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says action options run the middlewares. The change makes _runNested check for a specified action option, run it through the defining command's middleware, and stop the chain there. Tests cover --version as a runner global option action and branch and leaf action options, with middleware running around the action. The title names the main change. It follows the conventional commit style used by the commit message.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 457ee28b-c9a2-416b-941b-e2a38397a59d
Commits

Reviewing files that changed from the base of the PR and between b628aa8 and 371938a.

Files selected for processing: 3

  • packages/config/lib/src/command/command_runner.dart
  • packages/config/test/command/command_middleware_test.dart
  • packages/config/test/command/help_command_test.dart

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

@christerswahn
christerswahn merged commit ffb032d into main Nov 17, 2026
36 checks passed
@christerswahn
christerswahn deleted the new-command-runner branch November 17, 2026 13:57
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