question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Instances of Vorpal / Switching

See original GitHub issue

Hi, I’ve been working on the issue of multiple instances for a while now and it seems no matter what I do I do not get what seems to be separate instances of Vorpal. What I’m trying to accomplish is having multiple instances of vorpal that use a different set of commands(via use) and being able to switch through them.

In Case-1 below I try an example #56 given by dhtree as a solution to switching via multiple instances- I experience a lot of unexpected behavior, one of them being issues with tab-tab to get list of commands, and same for autocomplete using autocomplete-fs. It will return the commands 4 times for each tab-tab or as well as the autocomplete-fs directory results. Which suggests to me that there is only one instance being created of Vorpal. Even without the autocomplete, a regular tab will return 4 sets of commands. Aside from this behavior, command history also does not work properly when switching for me - the history is shared between the instances or new history is not recorded due to some unknown conflict.

In Case-2 which is another example given by dhtree the results are same as above, to me, suggesting there are not two seperate instances of vorpal but shared.

I would even take working with one instance of Vorpal and changing the commands it uses but I do not know of any way to remove .use from the instance to remove commands you have already issued .use(commands) on. The only downside of this is that it would not have separate attributes like autocomplete history and possibly others.

I’m really hoping I’m missing something - any ideas or solutions would be greatly appreciated!

Case-1 const Vorpal = require('vorpal'); const mainVorpal = new Vorpal(); const path = require('path'); const fsAutocomplete = require('vorpal-autocomplete-fs');

mainVorpal .delimiter('X:') .use(swap) .show();

function swap(mainVorpal) { mainVorpal.command('swap') .autocomplete(fsAutocomplete()) .action(function (args, cb) { instances[args.instance].show(); cb(); }); return mainVorpal; }

var instances = { 'a': new Vorpal().use(swap).delimiter('a:'), 'b': new Vorpal().use(swap).delimiter('b:'), 'c': new Vorpal().use(swap).delimiter('c:'), }

Case-2 function swap(mainVorpal) { mainVorpal.command('do <instance>') .action(function (args, cb) { console.log("walk"); cb(); }); return mainVorpal; }

function swap2(mainVorpal) { mainVorpal.command('say <instance>') .action(function (args, cb) { console.log("hello"); cb(); }); return mainVorpal; }

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

const unicorns = new Vorpal() .delimiter(chalk.magenta('unicorn-land~$')) .use(swap) .history('unicorn-command-history'); .show()

const narwhals = new Vorpal() .delimiter(chalk.cyan('narwhal-land~$')) .use(swap2) .history('narwhal-command-history');

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:24 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
benluxfordcommented, Aug 20, 2017

@omidnavi sure, I can have a little look at it, probably not till tomorrow sometime.

2reactions
benluxfordcommented, Aug 19, 2017

The repo I shared grabs all the folder names in the modules directory then adds them as modules. If you used the same code you would only be able to have module/submodule folders you would probably have to do something like modules/module1/submodules/submodule1 so that you can loop over the modules and the submodules folder within each module. There are probably other ways, this was the first that came to mind.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Switching between instances will exit · Issue #56 · dthree/vorpal ...
In one of your examples, you demonstrated how to switch between multiple instances. function switch(vorpal) { vorpal.command('switch ') .action(function ...
Read more >
Vorpal brand replaced by Heavy : r/dcss - Reddit
41 votes, 65 comments. Heavy increases a weapon's attack delay by 50%, but increases base damage by 80%. Yeah. Dark Maul is now...
Read more >
dthree/vorpal - Gitter
HI does anybody here knows how to have multiple instances and the ability to switch between them (like the cisco cli) ? I've...
Read more >
Darksiders Genesis | How to use Vorpal Blade - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >
Rebalancing Vorpal effects - Sword Coast Stratagems
If polyvorp was installed before mods that shouldn't be touched midgame, like Item Randomiser and SCS , the halberd will be awkward to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found