pkgjs / parseargs

Polyfill of `util.parseArgs()`
Apache License 2.0
122 stars 10 forks source link

Do not strip excess leading dashes on long option names #21

Closed shadowspawn closed 2 years ago

shadowspawn commented 2 years ago

Problem

All leading dashes on options are being stripped. This was to allow -foo treated the same as --foo for some circumstances, but that approach is being reconsidered to fully support short option flags and have simple consistent behaviour.

Note: the preflight checks in current limited code mean this is only affecting two or more dashes.

See #7 and #2

Solution

Only strip the two leading dashes of an option with two or more leading dashes.

---foo is parsed as an option named -foo.

(I followed the lint rules for the test file, rather than the local code style. I did not modify the rest of the file to pass the linter to keep this PR focused.)

shadowspawn commented 2 years ago

Test updated.

bcoe commented 2 years ago

Asking for forgiveness rather than permission, as this was open for a couple weeks 😆

I like this simplfication to the parser.