dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Regex syntax for command names #196

Open giocodes opened 7 years ago

giocodes commented 7 years ago

Is it possible to use regex syntax to define the name of a command, for example: vorpal .command(/\d/) // accepts any digit ...

The use case for this is to have dynamic commands that could include extra logic depending on the combination of words or digits.

A workaround could be, once the program is running through vorpal.show(); allow input without command and run them through a default action, instead of showing the error message.

Example:

vorpal .command([digits]) // accepts any digit instead of error message .action((args,callback) => { 'regex processing or any other use' ... })

Thank you!