fix(task): forward task help args and add raw_args#9118
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a raw_args configuration for tasks, allowing them to act as thin proxies by bypassing mise's argument parsing and forwarding all arguments, including --help and -h, directly to the underlying command. It also implements an escape hatch where arguments following a literal -- separator bypass the usage parser. The review feedback highlights an inconsistency in how subcommands are handled during the parser bypass check and recommends refactoring the duplicated bypass logic into a dedicated Task method to improve maintainability.
| .trailing_args | ||
| .iter() | ||
| .any(|a| a == "--help" || a == "-h"); | ||
| if !bypass_parser && has_any_args_defined(&spec) { |
There was a problem hiding this comment.
The condition has_any_args_defined(&spec) is inconsistent with the check in src/task/task_executor.rs. This check misses spec.cmd.subcommands, which can lead to incorrect argument parsing for tasks that only define subcommands.
To ensure consistent behavior, I recommend updating this to match the more comprehensive check in task_executor.rs.
| if !bypass_parser && has_any_args_defined(&spec) { | |
| if !bypass_parser && (!spec.cmd.args.is_empty() || !spec.cmd.flags.is_empty() || !spec.cmd.subcommands.is_empty()) { |
| let bypass_parser = self.raw_args | ||
| || self | ||
| .trailing_args | ||
| .iter() | ||
| .any(|a| a == "--help" || a == "-h"); |
There was a problem hiding this comment.
This logic for determining whether to bypass the usage parser is duplicated in src/task/task_executor.rs. To improve maintainability and prevent future inconsistencies, consider extracting this into a new method on the Task struct.
For example, you could add this method to impl Task:
pub fn should_bypass_usage_parser(&self) -> bool {
self.raw_args
|| self
.trailing_args
.iter()
.any(|a| a == "--help" || a == "-h")
}Then you can call this method here and in task_executor.rs.
| let bypass_parser = self.raw_args | |
| || self | |
| .trailing_args | |
| .iter() | |
| .any(|a| a == "--help" || a == "-h"); | |
| let bypass_parser = self.should_bypass_usage_parser(); |
Greptile SummaryThis PR adds Confidence Score: 5/5Safe to merge — no blocking issues found; all changed paths are exercised by e2e tests and the previous P1 predicate-duplication concern is resolved. All remaining findings are P2 or lower. Core logic (escape/unescape round-trip, bypass predicate, raw_args passthrough) is internally consistent and verified by unit and e2e tests. No files require special attention. Important Files Changed
Reviews (8): Last reviewed commit: "fix(task): preserve passthrough help arg..." | Re-trigger Greptile |
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.15 x -- echo |
23.8 ± 0.5 | 23.1 | 30.6 | 1.00 |
mise x -- echo |
24.5 ± 0.6 | 23.6 | 28.6 | 1.03 ± 0.03 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.15 env |
23.3 ± 0.7 | 22.5 | 30.9 | 1.00 |
mise env |
24.2 ± 0.5 | 22.9 | 26.0 | 1.04 ± 0.04 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.15 hook-env |
24.5 ± 0.4 | 23.6 | 25.8 | 1.00 |
mise hook-env |
25.1 ± 0.5 | 24.2 | 27.2 | 1.03 ± 0.02 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.4.15 ls |
21.4 ± 0.4 | 20.4 | 22.9 | 1.00 |
mise ls |
22.3 ± 0.8 | 21.2 | 33.2 | 1.04 ± 0.04 |
xtasks/test/perf
| Command | mise-2026.4.15 | mise | Variance |
|---|---|---|---|
| install (cached) | 155ms | 155ms | +0% |
| ls (cached) | 81ms | 82ms | -1% |
| bin-paths (cached) | 86ms | 87ms | -1% |
| task-ls (cached) | 793ms | 779ms | +1% |
The usage crate intercepts --help even when passed after `--`, so the documented escape hatch (`mise run task -- --help`) didn't actually reach the underlying script. This broke tasks that proxy tools with their own argument parsers (Django manage.py, next build, argparse scripts). Two changes: 1. `mise run task -- --help` (or `-- -h`) now bypasses the usage parser so --help reaches the script. Other args after `--` continue to be parsed as before. 2. New `raw_args = true` task option that always skips mise's argument parsing (including the --help interception in `mise run task --help`). Use this for thin proxy tasks where the underlying tool fully owns argument handling. Refs #5460 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback on #9118: - Extract the usage-parser bypass condition into `Task::should_bypass_usage_parser()` so the rule lives in one place instead of being duplicated across `render_run_scripts_with_args` and `parse_usage_spec_and_init_env`. - Honor an inner `--` inside the trailing args as an escape hatch: `mise run task -- -- --help` stops the bypass scan at the inner `--` so the usage parser sees `--help` as a literal positional value instead of triggering the help passthrough. - Extend `test_task_raw_args` with a file-task variant that exercises a real `\$@` proxy (inline TOML scripts can't, since args are appended to the command string) and with the inner-`--` escape case. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d52124a to
72040d1
Compare
|
Rebased on main and pushed a fixup commit addressing review feedback: Addressed:
Intentional / not changed:
CI failure ( This comment was generated by Claude Code. |
2c2af01 to
7e12df3
Compare
7e12df3 to
876f85c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 876f85c. Configure here.
876f85c to
62feb23
Compare
62feb23 to
0afc58e
Compare
0afc58e to
846510f
Compare
### 🚀 Features - **(registry)** add .perl-version support for perl by @ergofriend in [#9102](#9102) - **(task)** add Tera template support for inline table run tasks by @iamkroot in [#9079](#9079) ### 🐛 Bug Fixes - **(env)** use runtime symlink paths for fuzzy versions by @jdx in [#9143](#9143) - **(github)** use full token resolution chain for attestation verification by @jdx in [#9154](#9154) - **(go)** Remove install-time version override for subpath packages by @c22 in [#9135](#9135) - **(npm)** respect install_before when resolving dist-tag versions by @webkaz in [#9145](#9145) - **(self-update)** ensure subcommand exists by @salim-b in [#9144](#9144) - **(task)** show available tasks when run target missing by @jdx in [#9141](#9141) - **(task)** forward task help args and add raw_args by @jdx in [#9118](#9118) - **(task)** remove red/yellow from task prefix colors by @lechuckcaptain in [#8782](#8782) - **(task)** merge TOML task block into same-named file task and surface resolved dir by @jdx in [#9147](#9147) - **(toolset)** round-trip serialized tool options by @atharvasingh7007 in [#9124](#9124) - **(vfox)** fallback to absolute bin path if env_keys not set by @80avin in [#9151](#9151) ### 📚 Documentation - make agent guide wording generic by @jdx in [#9142](#9142) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:deb docker digest to e019cb9 by @renovate[bot] in [#9160](#9160) - update ghcr.io/jdx/mise:copr docker digest to 8d25608 by @renovate[bot] in [#9159](#9159) - update ghcr.io/jdx/mise:rpm docker digest to 22e52da by @renovate[bot] in [#9161](#9161) - update ghcr.io/jdx/mise:alpine docker digest to a3da97c by @renovate[bot] in [#9158](#9158) - update rust docker digest to 4a2ef38 by @renovate[bot] in [#9162](#9162) - update ubuntu:24.04 docker digest to c4a8d55 by @renovate[bot] in [#9164](#9164) - update rust crate aws-lc-rs to v1.16.3 by @renovate[bot] in [#9165](#9165) - update ubuntu docker tag to resolute-20260413 by @renovate[bot] in [#9169](#9169) - update rust crate clap to v4.6.1 by @renovate[bot] in [#9166](#9166) - update taiki-e/install-action digest to a2352fc by @renovate[bot] in [#9163](#9163) - update rust crate ctor to 0.10 by @renovate[bot] in [#9170](#9170) - update rust crate tokio to v1.52.1 by @renovate[bot] in [#9167](#9167) - update rust crate rmcp-macros to 0.17 by @renovate[bot] in [#9173](#9173) - update rust crate signal-hook to 0.4 by @renovate[bot] in [#9177](#9177) - update rust crate zipsign-api to 0.2 by @renovate[bot] in [#9180](#9180) - update rust crate toml_edit to 0.25 by @renovate[bot] in [#9179](#9179) - update rust crate strum to 0.28 by @renovate[bot] in [#9178](#9178) ### 📦 Registry - add ibmcloud by @dnwe in [#9139](#9139) - add rush by @jdx in [#9146](#9146) ### New Contributors - @80avin made their first contribution in [#9151](#9151) - @atharvasingh7007 made their first contribution in [#9124](#9124) - @lechuckcaptain made their first contribution in [#8782](#8782) - @ergofriend made their first contribution in [#9102](#9102) - @dnwe made their first contribution in [#9139](#9139) ## 📦 Aqua Registry Updates #### New Packages (3) - [`controlplaneio-fluxcd/flux-operator`](https://github.com/controlplaneio-fluxcd/flux-operator) - [`dependency-check/DependencyCheck`](https://github.com/dependency-check/DependencyCheck) - [`kiro.dev/kiro-cli`](https://github.com/kiro.dev/kiro-cli) #### Updated Packages (2) - [`jreleaser/jreleaser/standalone`](https://github.com/jreleaser/jreleaser/standalone) - [`sigstore/cosign`](https://github.com/sigstore/cosign)

Summary
--help/-hafter--to the task instead of letting the usage parser intercept it.raw_args = truefor task definitions and file headers so proxy tasks can skip mise/usage argument parsing entirely.--as the single boundary between mise parsing and task parsing:mise run task -- -- --helpforwards-- --helpto the task.runsubcommands intact when their command args contain a literalrunafter--, such asmise exec -- npm run test --help.Refs #5460.
Behavior
mise run task --helpwithout--and withoutraw_argsstill shows mise task help.Validation
cargo test --all-features cli::tests::test_escape_task_args_ignores_run_after_subcommand_separatorcargo fmt --checkgit diff --checktarget/debug/mise run test:e2e e2e/tasks/test_task_raw_argstarget/debug/mise run test:e2e e2e/tasks/test_task_helptarget/debug/mise exec -- bash -c 'printf "%s\n" "$*"' _ npm run test --helphkchecks during amendThis PR description was updated by Codex.
Note
Medium Risk
Changes core CLI argument preprocessing and task usage parsing, which can subtly affect how flags are routed between mise and tasks across multiple invocation forms.
Overview
Task execution now supports argument passthrough via new
raw_args = true, causing tasks to skip mise/usage argument parsing so all flags (including--help/-h) reach the underlying command.Separately, CLI preprocessing was adjusted so a literal
--is treated as the boundary between mise and task parsing:-- --helpbypasses the usage parser (even when a usage spec exists),-- -- --helpforwards-- --help, and non-runsubcommands with their own--tails are left untouched. Docs, JSON schemas, and e2e/unit tests were updated to cover the new behavior and edge cases.Reviewed by Cursor Bugbot for commit 846510f. Bugbot is set up for automated code reviews on this repo. Configure here.