-
Notifications
You must be signed in to change notification settings - Fork 53
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
Enforce single-hyphen properties, handle boolean array arguments #14
Conversation
Nope that's correct behavior as long as non-array Boolean arguments return true or false. |
I'm +1 on ensuring single |
New changes look good. Awaiting discussion in #11. |
index.js
Outdated
if (shortArg in handlers && | ||
Array.isArray(handlers[shortArg]) && | ||
rest.length > 0 && | ||
rest === argName.substring(1, 2).repeat(rest.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't appear this PR is designed to support -abc
right? Should it instead be iterating character by character until it sees a non-boolean, then treat the rest as the value of the first non-boolean key?
Edit: Feel free to ignore me, I see you're not trying to support it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as of now -abc
would be invalid because single-hyphen flags should be one character.
Expanding -abc
to equal -a -b -c
isn't a bad idea, but should be opened as another issue.
@pacocoursey mind splitting out the enforcement of a single letters and standalone |
Fixes #4 and #11.
Properties that start with a single hyphen and are longer than one character (like
-xyz
) now throw an error.Boolean array arguments now return a count of occurrences, rather than an array of booleans. For example,
./my-program -v -vvv
will return'-v': 4
.This also means that
./my-program -v
will return'-v': 1
. If that's undesired, let me know, and I'll fix it.