Skip to content

fix(@angular/cli): allow command arguments named help - #34609

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/help-positional-argument
Open

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/help-positional-argument

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Previously, localYargs.help('help', ...) was always enabled regardless of whether --help was passed. In Yargs, enabling .help() also registers an implicit help command/positional trigger, causing commands with a positional argument named help (such as ng generate component help) to display the CLI help output instead of executing the command.

Only enable Yargs help handling when --help is present in the parsed options.

Fixes #25705

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 30, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 30, 2026 14:28

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

Copy link
Copy Markdown

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 refactors an end-to-end test to use async/await syntax and adds a test case for generating a component named "help". It also updates the command runner to conditionally configure the help option. Feedback is provided regarding the Yargs .help() configuration, noting that passing a boolean as the first argument causes the custom description to be ignored, and suggests a TypeScript-safe alternative to preserve the description.

Comment thread packages/angular/cli/src/command-builder/command-runner.ts
@alan-agius4
alan-agius4 force-pushed the fix/help-positional-argument branch from 2897d3a to 2f0875d Compare October 30, 2026 14:35
Previously, `localYargs.help('help', ...)` was always enabled regardless of whether `--help` was passed. In Yargs, enabling `.help()` also registers an implicit `help` command/positional trigger, causing commands with a positional argument named `help` (such as `ng generate component help`) to display the CLI help output instead of executing the command.

Only enable Yargs help handling when `--help` is present in the parsed options.

Fixes angular#25705
@alan-agius4
alan-agius4 force-pushed the fix/help-positional-argument branch from 2f0875d to f48282a Compare October 30, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng generate m help does not generate module but shows help menu

1 participant