andrerpena andrerpena - 1 year ago 95
Javascript Question

Is it possible to create a Vorpal application which the command's output goes directly to the terminal, instead of it's own shell?

When you create Vorpal application, at least from what I see in the docs, it creates it's own shell. First, you enter that shell, and then you start executing commands. Like this:

user@computer: quotr
quotr$ snapshot
You triggered `snapshot`.

In the above example, the
command is being executed "inside" the Vorpal shell. It's output doesn't go directly to the terminal.

What I'm looking for is something like this:

user@computer: quotr snapshot
You triggered `snapshot`.

How can I achieve that with Vorpal?

Answer Source

Yes, you can do this with the vorpal.parse method, which will parse the arguments passed into Vorpal and execute them.

var vorpal = require('vorpal')();

  .action(function (args, cb) {
    this.log('You triggered `snapshot`.');


You can have the app exit after completing the command simply by omitting Because there is no prompt, Node realizes there is nothing left to do, and the process will exit naturally.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download