Skip to content

About undesired behaviour of wildcard routes in CLI #111

@diosney

Description

@diosney

Hi,

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 system command -> exec system handler

  • if entered system ANYTHING_BUT_CONFIGURED_ROUTES command -> exec system * handler, being ANYTHING_BUT_CONFIGURED_ROUTES anything 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 for system * is triggered instead of system 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.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions