I've the following routes in my CLI app:
system
system *
system info
system info *
system settings
system settings *
system tunables
system tunables *
system logging
system logging *
system logging settings
system logging settings *
and want a behaviour like this:
- if entered
systemcommand -> execsystemhandler if entered
system ANYTHING_BUT_CONFIGURED_ROUTEScommand -> execsystem *handler, beingANYTHING_BUT_CONFIGURED_ROUTESanything else but:info settings tunables logging
The issue is related app.cmd() execution order:
if I register the routes in inverse order than above the handlers are executed properly
if I register the routes in the same order than above, if I execute
system info, the handler forsystem *is triggered instead ofsystem info.
Any suggestion on how overcome this?
I'm solving this currently by looping and contructing an inverse array and then looping again, but this takes a lot of time for a simple CLI app and this is cumbersome, so I'm looking for a different solution.
Not knowing the modules you use, the problem makes sense, it's matching on first found, not most specific... but you don't have to completely rearrange your list, just put the wildcards after the specific entries, like so: