Closed tobilg closed 8 years ago
Well, you can always go back and edit a command, or remove it and re-create it, so you could re-build commands dynamically with some sort of meta data:
const options = ['toppings', 'foo', 'bar'];
for (let i = 0; i < options.length; ++i) {
vorpal.find('metacmd').option(options[i]);
}
This is a super simple example, but you can add as much metadata as you want to it.
Another pertinent command would be vorpal.find('metacmd').remove()
;
Would you mind posting this on Stack Overflow? In this way, others with the same question can benefit easier!
Thanks a lot for the fast answer. I'll post the question to SO later today.
Is it possible to configure the option list dynamically instead of statically chaining the
option()
tovorpal.command()
?Background is I want to be able to create my vorpal commands from some kind of metadata objects, i.e. I want to save some work for commands which work similarly by generating those commands based on a definition.