Skip to content

Forward --help/--version to task in run alias#54

Merged
kjanat merged 1 commit into
masterfrom
feat/run-forward-help-version
Jun 14, 2026
Merged

Forward --help/--version to task in run alias#54
kjanat merged 1 commit into
masterfrom
feat/run-forward-help-version

Conversation

@kjanat

@kjanat kjanat commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

The run alias now intelligently forwards --help and --version flags to the task when they follow a task name, while still printing the binary's own help/version when these flags appear before any task.

Changes

  • Disabled clap's built-in help/version flags on RunAliasCli to prevent them from short-circuiting parsing. This allows trailing help/version flags to be captured by the args field and forwarded to the task instead.

  • Added builtin request detection via new alias_builtin_request() function that classifies parse errors as help/version requests. When a help/version flag appears before any task, it cannot fill the hyphen-rejecting task positional and surfaces as an UnknownArgument error, which is now recognized as a request for the binary's own help/version.

  • Implemented help/version handling in run_alias_in_dir() that:

    • Detects leading help/version flags via error classification
    • Calls new print_run_alias_help() function for help requests
    • Prints version info for version requests
    • Falls back to rendering clap errors for unrelated parse failures
  • Updated help text to document the new behavior: help/version flags before a task print the binary's own help/version, while those after a task are forwarded. The -- separator can force literal forwarding.

Behavior

  • run --help → prints run alias help
  • run --pm npm --help → prints run alias help (flag before task)
  • run <task> --help → forwards to task (flag after task)
  • run <task> -- --help → forwards literally (after separator)
  • run <task> -h → forwards to task (short form)

The runner run subcommand behavior is unchanged.

`run <task> --help` (and -h/-V/--version) now reach the task's own
help/version instead of printing the `run` alias's, removing the need
for `run <task> -- --help`. Bare `run --help`/`--version`, including
after global flags (`run --pm npm --help`), still print the alias's own
help/version, and `run <task> -- --help` still forwards literally.

clap's built-in help/version flags short-circuit parsing wherever they
appear, so they are disabled on RunAliasCli and left undefined. An
undefined hyphen token after the first positional is swallowed by `args`
(trailing_var_arg) and forwarded; a leading one can't fill the
hyphen-rejecting `task` positional and surfaces as UnknownArgument, which
run_alias_in_dir classifies as the alias's own help/version request. Since
-h/--help/-V/--version are no longer clap args, they are documented in the
help footer (after_help) rather than the options list.

The `runner run` subcommand is intentionally unchanged.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
runner 9213583 Commit Preview URL

Branch Preview URL
Jun 14 2026, 09:49 AM

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • cr:review
🚫 Excluded labels (none allowed) (2)
  • wip
  • cr:skip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1af6ac8f-84df-4b6f-81eb-17d74841db25

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The run alias CLI (RunAliasCli) now disables clap's built-in -h/--help and -V/--version flags and instead documents them in an after_help footer. A new private AliasBuiltin enum and associated helpers in src/lib.rs inspect clap UnknownArgument errors to determine whether the failing argument was a help or version flag. run_alias_in_dir intercepts these classified errors, prints the alias binary's own help or version output, and returns exit code 0. Flags appearing after a task name continue to be forwarded to the task. Tests and a CHANGELOG.md entry cover the new behaviour.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

⚓ Arrr, me hearties, hoist the --help high!
No more shall flags be swallowed by the tide,
If ye place yer -h before the task's name,
This binary shows its colours, bold with pride.
But after a task? It sails to the other side! 🏴‍☠️
nyaa~ The version flag is finally home, right where it belongs~! ✨

🚥 Pre-merge checks | ✅ 7 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Semver Version Bump Validation ⚠️ Warning Source code modified (196 lines changed across src/cli.rs and src/lib.rs) with new features documented in CHANGELOG as "Changed", but version remains at 0.13.0 with no SemVer bump. Increment Cargo.toml version to 0.14.0 (MINOR bump) to reflect the backward-compatible feature addition documented in CHANGELOG.
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely describes the main change: forwarding help/version flags to tasks in the run alias, following conventional commit guidelines with descriptive verb.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 30.00%.
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.
Changelog Update ✅ Passed Source code files (src/cli.rs, src/lib.rs) modified with substantial feature changes; CHANGELOG.md properly updated under [Unreleased] section with "Changed" subsection describing the run alias hel...
Agents.Md Documentation Updated ✅ Passed No AGENTS.md file exists in the repository, so the check condition is not applicable. PR modifies run alias CLI but there's no AGENTS documentation to update.
Description check ✅ Passed The description clearly explains the intelligent forwarding of help/version flags and the implementation strategy, directly matching the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@kjanat kjanat self-assigned this Jun 14, 2026
@kjanat kjanat marked this pull request as ready for review June 14, 2026 16:18
@kjanat kjanat added cr:review Allow CodeRabbit review cr:skip Skip CodeRabbit review and removed cr:review Allow CodeRabbit review labels Jun 14, 2026
@kjanat kjanat force-pushed the feat/run-forward-help-version branch from 9213583 to 7d511ff Compare June 14, 2026 16:26
@kjanat kjanat merged commit e192b44 into master Jun 14, 2026
18 checks passed
@kjanat kjanat deleted the feat/run-forward-help-version branch June 14, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cr:skip Skip CodeRabbit review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant