Skip to content

fix: show usage help when long_about is defined w/o args/flags#8824

Merged
jdx merged 5 commits intojdx:mainfrom
nkakouros:worktree-fix-long-about-no-args
Mar 31, 2026
Merged

fix: show usage help when long_about is defined w/o args/flags#8824
jdx merged 5 commits intojdx:mainfrom
nkakouros:worktree-fix-long-about-no-args

Conversation

@nkakouros
Copy link
Copy Markdown
Contributor

Description:

Summary

  • When a task script defines #USAGE long_about (or other metadata-only directives like before_help, after_help, examples) but no arg or flag, mise run task --help now correctly renders usage-based help instead of the generic "This task does not accept any arguments" message.
  • Adds a new has_any_usage_spec() function that checks for any meaningful usage spec content (not just args/flags/subcommands), used only for the help display decision. The existing has_any_args_defined() remains unchanged for runtime argument parsing.

Steps to reproduce

mkdir -p .mise/tasks
cat <<'EOF' > .mise/tasks/example
#!/usr/bin/env bash
#USAGE long_about """
#USAGE Detailed description here.
#USAGE """
echo "hello"
EOF
chmod +x .mise/tasks/example
                                                                                                                                                                                                                                                                   
mise run example --help
# Before: shows generic "This task does not accept any arguments"
# After: shows "Detailed description here."                                                                                                                                                                                                                       

Test plan

  • Added e2e test for long_about without args/flags (test_task_args_position test 9)
  • All existing e2e tests for test_task_args_position pass
  • All 546 unit tests pass

…rgs/flags

When a task script defines #USAGE long_about (or other metadata directives)
but no args or flags, --help now correctly shows the usage-rendered help
instead of the generic "This task does not accept any arguments" message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the task help system by introducing the has_any_usage_spec function, which ensures that usage-based help is displayed if any usage metadata (such as long_about) is present, even if no arguments or flags are defined. A new end-to-end test was added to verify this behavior. The reviewer identified that spec.about and spec.cmd.help_md were missing from the new check and provided a code suggestion to include them for more comprehensive coverage.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR fixes a display bug where mise run <task> --help showed the generic "This task does not accept any arguments" message when a task script defined only metadata-only USAGE directives (e.g. long_about, before_help, after_help, examples) without any formal args or flags.

Key changes:

  • Introduces has_any_usage_spec() in task_script_parser.rs that broadens the help-routing decision beyond args/flags/subcommands to include metadata fields (about, about_long, about_md, help_long, help_md, before_help, after_help, after_help_long, examples).
  • before_help_long is deliberately excluded from the check because populate_spec_metadata() auto-sets it for any task with depends entries — this addresses the previously reported false-positive regression.
  • src/cli/run.rs is updated to call the new guard, and the old has_any_args_defined remains unchanged for runtime argument parsing.
  • An e2e test (Test 9 in test_task_args_position) validates the fix end-to-end.

Confidence Score: 5/5

  • Safe to merge — targeted fix with no regressions; the prior before_help_long false-positive is correctly excluded.
  • All changed fields in has_any_usage_spec are only populated by explicit user-defined USAGE directives, not by populate_spec_metadata auto-filling. The one auto-set field (before_help_long) is explicitly excluded with a doc comment. The fix is minimal, well-scoped, and backed by both an e2e test and all 546 passing unit tests.
  • No files require special attention.

Important Files Changed

Filename Overview
src/task/task_script_parser.rs Adds has_any_usage_spec() that checks for meaningful usage content (about, about_long, help_long, before_help, after_help, examples) on top of has_any_args_defined(); correctly excludes before_help_long which is auto-set by populate_spec_metadata for dependency tasks.
src/cli/run.rs Swaps the help-display guard from has_any_args_defined to has_any_usage_spec, enabling metadata-only specs (e.g. long_about without args) to trigger usage-based rendering.
src/task/mod.rs Re-exports the new has_any_usage_spec function alongside the existing has_any_args_defined; no logic changes here.
e2e/tasks/test_task_args_position Adds Test 9 covering the long_about-only case, creating a temporary task file and asserting the help output contains the description text.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["mise run &lt;task&gt; --help"] --> B["parse_usage_spec_for_display()"]
    B --> C["populate_spec_metadata()"]
    C --> D{"has_any_usage_spec(spec)?"}
    D -->|"args / flags / subcommands\nOR about / about_long / about_md\nOR help_long / help_md\nOR before_help / after_help / after_help_long\nOR examples"| E["render_help() — usage-based help"]
    D -->|"None of the above\n(note: before_help_long is\nauto-set for depends, so excluded)"| F["display_task_help() — generic fallback"]
Loading

Reviews (4): Last reviewed commit: "fix(task): include before_help in has_an..." | Re-trigger Greptile

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@nkakouros nkakouros marked this pull request as draft March 30, 2026 20:18
nkakouros and others added 2 commits March 30, 2026 23:19
before_help_long is set automatically by populate_spec_metadata() for tasks
with dependencies, causing a false positive that would switch those tasks
to usage-based help rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nkakouros nkakouros marked this pull request as ready for review March 30, 2026 20:53
Only before_help_long is auto-populated by populate_spec_metadata() for
tasks with dependencies. before_help (without _long) is only set from
explicit #USAGE directives, so it's safe to include.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jdx jdx merged commit 2eafaf5 into jdx:main Mar 31, 2026
34 checks passed
mise-en-dev added a commit that referenced this pull request Apr 1, 2026
### 🚀 Features

- add azd (Azure Developer CLI) to registry by @rajeshkamal5050 in
[#8828](#8828)

### 🐛 Bug Fixes

- **(aqua)** skip registry lookup for linked versions in list_bin_paths
by @nikobockerman in [#8801](#8801)
- **(rust)** handle rustup check exit code 100 as non-error by @shalk in
[#8832](#8832)
- **(task)** resolve bare aliases in monorepo with config_roots by
@nkakouros in [#8819](#8819)
- show usage help when long_about is defined w/o args/flags by
@nkakouros in [#8824](#8824)

### 📚 Documentation

- fix serif font in sidebar and increase heading sizes by @jdx in
[#8831](#8831)
- fix #vscode link in ide integration page by @jedymatt in
[#8833](#8833)
- fix nested Markdown code fences by @muzimuzhi in
[#8835](#8835)

### New Contributors

- @shalk made their first contribution in
[#8832](#8832)
- @jedymatt made their first contribution in
[#8833](#8833)
- @nikobockerman made their first contribution in
[#8801](#8801)
- @rajeshkamal5050 made their first contribution in
[#8828](#8828)

## 📦 Aqua Registry Updates

#### New Packages (2)

- [`gastownhall/beads`](https://github.com/gastownhall/beads)
- [`getdbt.com/dbt-fusion`](https://github.com/getdbt.com/dbt-fusion)

#### Updated Packages (2)

- [`Azure/azure-dev`](https://github.com/Azure/azure-dev)
- [`magefile/mage`](https://github.com/magefile/mage)
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.

3 participants