type-flag
type-flag copied to clipboard
feat: support single-character flags
Closes #26
Changes:
- removed the check against 1-character
flagName
s - added a check against 1-character flags with an alias defined
Tests:
- removed the test making sure 1-character flags were disallowed
- added a test making sure 1-character flag names work
- added a test making sure 1-character flag names can be used in alias groups along with longer flags (
git commit -am hello
)
Note:
I was surprised it was as easy as this. And from playing around it seems that type-flag doesn't seem to care if you use --
or -
, for flags of any length. For example foo --message hello
and foo -message hello
both seem to work. Likewise foo -m hello
and foo --m hello
.
I wasn't sure if this was deliberate, I couldn't find it in the docs. But either way, I wanted to get this in along with test cases. So if the above is considered a bug, not regressing support for single-character flags would be part of the fix requirements if this goes in first.
Another note:
For this to make its way to cleye, there might be some special-casing needed for the --help
renderer (to avoid suggesting --x 1
usage instead of -x 1
(although both work as noted above)). I can help with that too if you'd like, once this or something like it is published.