Skip to content
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

feat: support single-character flags #27

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mmkal
Copy link
Sponsor

@mmkal mmkal commented Jun 18, 2024

Closes #26

Changes:

  • removed the check against 1-character flagNames
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support single-character flags
1 participant