-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bug in regex for lone short flag #2227
Comments
Short flags with more than one character are not supported. Short flags are a dash followed by a single character. See #2211 for more details. (Feel free to ask if you have more questions.) |
Thanks @shadowspawn! That makes sense. But if Java-style short flags are intentionally not supported, shouldn't |
For background, I didn't want to immediately break existing programs when I first found that people were specifying multi-character short flags that were not intended. So the first steps we took were to clarify README and saying this was not supported (#937 #1718). It hasn't come up often since then, but it could be time to add an error since unsupported option syntax has come up 3 times in last month! (#2211 #2222 #2227)
Correct. POSIX has clear rules for specifying short option and option-value, and The few applications I am familiar with that allow |
Closing in favour of #2235, adding an error for short flag longer than one character |
FYI, there is a recent issue asking to allow multiple character short options in Commander 13: #2307 |
#1256 added a support for lone short flag.
Unfortunately, this only works correctly on short flags with one character. Short flags with multiple characters (Java-style short flags) will incorrectly create incorrect field names. For example,
.option('-name')
will result in a fieldName
, which is not in camelCase.The reason is that this regex only matches a short flag with one character. This means a short flag with multiple characters will be categorized as a long flag. Consequently, Commander.js attempts to strip
--
from-name
, which is a no-op, resulting in-name
. Then, the camel case conversion of-name
results inName
, which is not a camel case as intended.The text was updated successfully, but these errors were encountered: