-
-
Notifications
You must be signed in to change notification settings - Fork 769
fix(cli): intercept --help flag to show task help instead of executing task #6955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where mise run --cd <dir> <task> --help would execute the task with --help as an argument instead of displaying the task's help information.
Key Changes:
- Added early interception of
--help/-hflags inRun::run()to show task help before execution - Modified behavior to consistently display help for all tasks, regardless of whether they have usage specifications
- Added test coverage for the
--cdflag scenario and updated existing help tests
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/cli/run.rs | Intercepts --help/-h flags before task execution and renders help using the usage library |
| e2e/tasks/test_task_help_with_cd | New test verifying --help works correctly with --cd flag for tasks with and without usage specs |
| e2e/tasks/test_task_help | Updated assertions to reflect new behavior where --help always shows help instead of being passed to task scripts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Build args list to get the task | ||
| let args = once(self.task.clone()) | ||
| .chain(self.args.clone()) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After removing --help/-h from self.args on lines 209-210, these flags are still present in self.args_last. The args construction here doesn't use self.args_last, which could cause the task resolution to miss arguments that were originally in self.args_last. Consider chaining self.args_last as well, similar to how it's done elsewhere in the run logic.
| .chain(self.args.clone()) | |
| .chain(self.args.clone()) | |
| .chain(self.args_last.clone()) |
| // Remove --help/-h from args to get the task | ||
| self.args.retain(|arg| arg != "--help" && arg != "-h"); | ||
| self.args_last.retain(|arg| arg != "--help" && arg != "-h"); | ||
|
|
||
| // Build args list to get the task | ||
| let args = once(self.task.clone()) | ||
| .chain(self.args.clone()) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutating self.args and self.args_last could have unintended side effects if these fields are used later. Consider using local variables with filtered values instead of mutating the struct fields directly.
| // Remove --help/-h from args to get the task | |
| self.args.retain(|arg| arg != "--help" && arg != "-h"); | |
| self.args_last.retain(|arg| arg != "--help" && arg != "-h"); | |
| // Build args list to get the task | |
| let args = once(self.task.clone()) | |
| .chain(self.args.clone()) | |
| // Remove --help/-h from args to get the task using local variables | |
| let filtered_args = self.args.iter().filter(|arg| *arg != "--help" && *arg != "-h").cloned(); | |
| let filtered_args_last = self.args_last.iter().filter(|arg| *arg != "--help" && *arg != "-h").cloned(); | |
| // Build args list to get the task | |
| let args = once(self.task.clone()) | |
| .chain(filtered_args) |
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.3 x -- echo |
19.1 ± 1.6 | 18.0 | 37.4 | 1.02 ± 0.09 |
mise x -- echo |
18.6 ± 0.3 | 18.0 | 19.9 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.3 env |
18.0 ± 0.4 | 17.4 | 21.7 | 1.00 |
mise env |
18.3 ± 0.4 | 17.6 | 21.3 | 1.02 ± 0.03 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.3 hook-env |
18.2 ± 0.7 | 17.5 | 29.1 | 1.00 |
mise hook-env |
18.5 ± 0.5 | 17.7 | 21.6 | 1.01 ± 0.05 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.3 ls |
16.0 ± 0.5 | 15.2 | 17.4 | 1.00 |
mise ls |
16.0 ± 0.7 | 15.1 | 24.1 | 1.00 ± 0.05 |
xtasks/test/perf
| Command | mise-2025.11.3 | mise | Variance |
|---|---|---|---|
| install (cached) | 104ms | 105ms | +0% |
| ls (cached) | 66ms | 66ms | +0% |
| bin-paths (cached) | 72ms | 73ms | -1% |
| task-ls (cached) | 420ms | 426ms | -1% |
…g task When running `mise run task --help` or `mise task --help`, the --help flag is now intercepted to display help for the task using the usage library, instead of passing --help as an argument to the task script. This fixes the issue where tasks without usage specifications (no arg() calls) would execute with --help as an argument instead of showing help. Changes: - Intercept --help/-h flags in Run::run() before task execution - Use usage::docs::cli::render_help() to display task help consistently - Update test_task_help to reflect new behavior - Add test_task_help_with_cd to verify --help works with --cd flag Fixes behavior for both `mise run task --help` and naked runs like `mise task --help` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
73a8a7e to
a2161bf
Compare
### 📦 Registry - add xcsift by @alexey1312 in [#6923](#6923) - add tools: magika & xxh by @IceCodeNew in [#6909](#6909) - add aliases to aqua-backend tools by @IceCodeNew in [#6910](#6910) ### 🚀 Features - **(tasks)** add `mise task validate` command for task validation by @jdx in [#6958](#6958) ### 🐛 Bug Fixes - **(cli)** intercept --help flag to show task help instead of executing task by @jdx in [#6955](#6955) - remove temporary files after install by @vmeurisse in [#6948](#6948) ### 📚 Documentation - **(snapcraft)** update `summary` & `description` shown in snapcraft.io by @phanect in [#6926](#6926) - Change package example in go.md by @nachtjasmin in [#6862](#6862) - paranoid mode does not untrust global config by @iloveitaly in [#6952](#6952) ### 📦️ Dependency Updates - lock file maintenance by @renovate[bot] in [#6932](#6932) ### New Contributors - @iloveitaly made their first contribution in [#6952](#6952) - @nachtjasmin made their first contribution in [#6862](#6862) - @IceCodeNew made their first contribution in [#6910](#6910) - @alexey1312 made their first contribution in [#6923](#6923) ## 📦 Aqua Registry Updates #### New Packages (6) - [`CrociDB/bulletty`](https://github.com/CrociDB/bulletty) - [`Gaurav-Gosain/tuios`](https://github.com/Gaurav-Gosain/tuios) - [`ck-zhang/reddix`](https://github.com/ck-zhang/reddix) - [`hokaccha/spannerdef`](https://github.com/hokaccha/spannerdef) - [`lasantosr/intelli-shell`](https://github.com/lasantosr/intelli-shell) - [`zerocore-ai/microsandbox`](https://github.com/zerocore-ai/microsandbox) #### Updated Packages (4) - [`cue-lang/cue`](https://github.com/cue-lang/cue) - [`flutter/flutter`](https://github.com/flutter/flutter) - [`phiresky/ripgrep-all`](https://github.com/phiresky/ripgrep-all) - [`topgrade-rs/topgrade`](https://github.com/topgrade-rs/topgrade) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Bump to 2025.11.4 with aqua-registry additions/updates, dependency/tooling refresh, updated completions/docs, and packaging/version files. > > - **Release/Versioning**: > - Bump to `2025.11.4` in `Cargo.toml`, `default.nix`, `packaging/rpm/mise.spec`, `snapcraft.yaml`, and `README.md`. > - **Aqua Registry**: > - *New packages*: `CrociDB/bulletty`, `Gaurav-Gosain/tuios`, `ck-zhang/reddix`, `hokaccha/spannerdef`, `lasantosr/intelli-shell`, `zerocore-ai/microsandbox` (owner change + aliases). > - *Updates*: `cue-lang/cue` (version rules), `flutter/flutter` (channelized URLs), `phiresky/ripgrep-all` (version/asset rules), `topgrade-rs/topgrade` (extensive version/asset overrides). > - **Dependencies/Tooling**: > - `Cargo.lock`: bump `aws-lc-*`, `hyper 1.8.0`, `indicatif 0.18.3`, `luajit-src`, `num-bigint-dig`, `crypto-common`, `usage-lib`, etc. > - `mise.lock`: update `bun`, `cargo-binstall`, `cargo-edit`, `node`, `pre-commit`, `usage-cli`. > - **Completions**: > - Update usage spec cache filenames to `usage__usage_spec_mise_2025_11_4.spec` in `completions/*`. > - **Docs**: > - Add `CHANGELOG.md` entry for `2025.11.4`; bump stars to `21.3k` in `docs/.vitepress/stars.data.ts`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a1e62ee. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Summary
Fixes the issue where
mise run --cd <dir> <task> --helpwould execute the task with--helpas an argument instead of displaying help for the task.Problem
When running commands like:
The
--helpflag was being passed to the task script as an argument, causing the task to run instead of showing help. This was particularly problematic for tasks without usage specifications (noarg()calls).Solution
--helpand-hflags inRun::run()before task executionusage::docs::cli::render_help()to consistently display task helpmise run task --helpand naked runs likemise task --helpChanges
Modified
src/cli/run.rs:--help/-hin args before task executionAdded
e2e/tasks/test_task_help_with_cd:--helpwith--cdflagUpdated
e2e/tasks/test_task_help:--helpalways shows helpBehavior Changes
Before: Tasks without usage specs would pass
--helpto the scriptAfter: All tasks show help when
--helpis providedTesting
--cdflag usage🤖 Generated with Claude Code
Note
Intercepts --help/-h in
mise runto display task help (respecting--passthrough), adds--cde2e coverage, and updates help-related tests.src/cli/run.rs, detect--help/-hinself.argsbefore execution (excluding args after--), strip them, resolve the task, and render help viausage::docs::cli::render_help; fallback to run command help if no task is found.e2e/tasks/test_task_help_with_cdto verifymise run --cd <dir> <task> --help, passthrough behavior with--, and tasks with/without usage specs.e2e/tasks/test_task_helpto assert help is shown for tasks (including extra args) and to clarify--passes--helpto the task script.Written by Cursor Bugbot for commit a2161bf. This will update automatically on new commits. Configure here.