Skip to content
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

fix: coerce should play well with parser configuration #2308

Merged
merged 7 commits into from Apr 28, 2023

Conversation

shadowspawn
Copy link
Member

@shadowspawn shadowspawn commented Mar 10, 2023

Relates to #2307 and #2161. Yargs does the coerce separately after yargs-parser, and should both apply the coerce values to the aliases and camel-case variations, but also not add them back if the parser configuration said not to include them in the results.

Use the fact that yargs-parser has already decided what variations belong in the results, and update just the naming variations already present in the results.

Fixes #2307, fixes #2311

@shadowspawn
Copy link
Member Author

shadowspawn commented Mar 10, 2023

I noticed a subtle problem that if strip-dashed is true then the argv does not contain the parsed option with the dashed name so coerce is ignored, although the option was present in the input arguments. May or may not attempt to fix that in this PR too... So many permutations!

  • camel-case expansion
  • strip-aliased
  • strip-dashed

@shadowspawn
Copy link
Member Author

In #1872 coerce handling got promoted out of yargs-parser to support async, so the current code is relatively new and has been iteratively improving to fully reimplement the original behaviours and coverage.

@shadowspawn
Copy link
Member Author

shadowspawn commented Mar 10, 2023

Looking at the yargs-parser implementation, that code works with argv and aliases without checking configuration options. That makes me more confident that heading in the right direction in this PR.

@bcoe
Copy link
Member

bcoe commented Mar 13, 2023

@shadowspawn thanks for the contribution 😄

@bcoe bcoe merged commit 8343c66 into yargs:main Apr 28, 2023
7 checks passed
@shadowspawn shadowspawn deleted the fix/2307 branch May 8, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants