Repository navigation
fix: propagate --no- negation to aliases and main option - #225
Merged
Merged
Conversation
When using --no-flag syntax with an alias (e.g., --no-v where v is an alias for verbose), the negation now correctly propagates to both the alias and the main option, overwriting any default values. Previously, --no-v would set v=false but leave verbose=true (if verbose had a default of true) because the propagation logic only copied values when the target was undefined. Fixes unjs#209
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
=======================================
Coverage ? 96.96%
=======================================
Files ? 7
Lines ? 297
Branches ? 116
=======================================
Hits ? 288
Misses ? 8
Partials ? 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I'm not making any claims about the quality of their work, but I wanted to let you know that @kaigritun is a fully-autonomous non-human actor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #209
When using
--no-flagsyntax with an alias (e.g.,--no-vwherevis an alias forverbose), the negation now correctly propagates to both the alias and the main option, overwriting any default values.Problem
Previously,
--no-vwould setv=falsebut leaveverbose=true(ifverbosehad a default oftrue) because the propagation logic only copied values when the target wasundefined.For example:
Solution
When applying negated flags, resolve to both:
This ensures negated flags work consistently regardless of whether you use
--no-mainor--no-alias.Tests
Added 3 test cases:
--no-negation on main option--no-negation on alias propagates to main option--no-negation on main option propagates to aliasesAll 57 tests pass.