dthree / vorpal

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

Tab-tab to get a list of commands, not working properly when using multiple instances of Vorpal #217

Open mke66djx opened 7 years ago

mke66djx commented 7 years ago

Hi guys, I recently found what I think is an undesired result when using tab-tab to get available commands while using multiple Vorpal instances. Using the exact example on the Vorpal page(http://vorpal.js.org/) (customization example), if you simply create two lists of commands to use via .use, and run the below you will get all of the functions for all instances and it will essentially display the delimiter and each instances commands for as many instances as you have. I've been trying to debug this for a day or so now, any feedback would be great: Example: const Vorpal = require('vorpal'); const chalk = Vorpal().chalk; const unicorns = Vorpal() .delimiter(chalk.magenta('unicorn-land~$')) .use(require('./commands/campaignModeCmds')) .history('unicorn-command-history'); const narwhals = Vorpal() .delimiter(chalk.cyan('narwhal-land~$')) .use(require('./commands/dataModeCmds')) .history('narwhal-command-history'); unicorns .show() .parse(process.argv);

mke66djx commented 7 years ago

Adding on to this; a further look and it seems that the problem can be observed even when doing something like the below. If run as is and hit tab twice, you will get two sets of the available commands. If you emit the chalk line however you will see the correct output when hitting tab twice

const Vorpal = require('vorpal'); const chalk = Vorpal().chalk;

const unicorns = Vorpal() .delimiter('unicorn-land~$');

unicorns .show();