Skip to content

fix: reveal hidden options with --show-hidden when strip-dashed is set - #2592

Closed
Yahiro025 wants to merge 1 commit into
yargs:mainfrom
Yahiro025:cursor/fix-show-hidden-strip-dashed-2356
Closed

Yahiro025 wants to merge 1 commit into
yargs:mainfrom
Yahiro025:cursor/fix-show-hidden-strip-dashed-2356

Conversation

@Yahiro025

Copy link
Copy Markdown

Description

Fixes #2356.

When parserConfiguration({ 'strip-dashed': true }) is enabled, yargs-parser stores camelCased keys on argv (showHidden instead of show-hidden). filterHiddenOptions only looked up argv[showHiddenOpt], so --show-hidden (and custom show-hidden flag names) never revealed hidden options in help output.

This is a minimal fix in lib/usage.ts: also check the camelCase and kebab-case forms of the configured show-hidden option key. Intentionally smaller than #2516 (closed as too heavy for this edge case).

Motivation and Context

--help --show-hidden should list hidden options even when strip-dashed is on. Without this, apps that prefer camelCase argv silently lose the ability to surface hidden options via the documented flag.

How Has This Been Tested?

  • Added regression tests in test/usage.mjs for:
    • default --show-hidden + strip-dashed
    • custom showHidden('custom-show-hidden') + strip-dashed
    • alias of show-hidden + strip-dashed
  • Ran existing hidden options suite and the strip-dashed conflict validation test — all passing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (no docs change — behavior restored to documented intent)
  • I have added tests to cover my changes.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

When parserConfiguration({ 'strip-dashed': true }) is enabled, argv stores
showHidden instead of show-hidden, so filterHiddenOptions never saw the flag.
Check camelCase and kebab-case keys so --show-hidden (and custom names) work.

Fixes yargs#2356
@shadowspawn

Copy link
Copy Markdown
Member

This looks like a drive-by AI contribution.

This may get looked at and used when the issue is prioritised.

The human maintainer does not have time to review all AI heavy PRs that are opened.

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.

show-hidden broken if parser has strip-dashed config

2 participants