Fix short option with an embedded =
later in the argument
#6
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.
Problem
A short option with an embedded
=
later in the argument is parsed inconsistently and with data loss.In particular:
-a=b=c
gives same result as-a=b
(lost trailing=c
)-ab=c
gives same result as-a=c
(lost leadingb
)Fixes #5
Solution
Make code more explicit and test for
=
at start when looking for possible value.-a=b=c
makes optiona
have valueb=c
.-ab=c
makes optiona
true and optionb
have valuec
.(In my first commit I made
-ab=c
give optionb
the value=c
by only treating the=
as special at the start. I checked Yargs and found it set value toc
. I can see a rationale for the parsing to treat it like an expansion, so-ab=c
=>-a
-b=c
, and optionb
has valuec
. More comfortable matching Yargs with this behaviour.)