clue / commander

Finally a sane way to register available commands and arguments and match your command line in PHP
MIT License
169 stars 8 forks source link

Support combined short options from user input #4

Open clue opened 7 years ago

clue commented 7 years ago

We should support matching combined short options:

add [-i] [-a] [-d=<X>] [-w=<X>]

All add -i -a, add -ia and add -ai should result in the same match.

Also, short options with values (depends on #3) may be even trickier.

Depends on #2.

clue commented 7 years ago

For the reference: This ticket hasn't seen any progress because it's actually quite tricky. Its syntax does in fact collide with concatenated values for short options as implemented in #12.

add -iwa should be interpreted as add -i -w=a and not as add -i -w -a.

This means that we can only consume combined short options beginning from the first letter and then checking each occurrence if it accepts a value.

This change will likely require a major refactoring, because we currently consume individual tokens from the route expression the order they're defined in. We may now have to also check combined options in the order they're passed in.