dthree / vorpal

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

Prompt is not working with Vorpal parse #164

Closed alansouzati closed 8 years ago

alansouzati commented 8 years ago

If my command has a prompt and I'm using vorpal parse, I cannot get the prompt to display the question and the CLI finishes without any log or error which makes it harder to debug.

import vorpal from 'vorpal'

const cli = vorpal();

cli
    .command('fakeCommand', 'This is just a demo')
    .action(function (args, cb) {
      this.prompt({
        type: 'input',
        name: 'basePath',
        default: process.cwd(),
        message: 'Destination folder (if empty, current folder will be used)?'
      }, (result) => {
          console.log('hi');
          cb();
     });
    });

This does not work

node cli.js fakeCommand

This works

  1. node cli.js
  2. fakeCommand
alansouzati commented 8 years ago

_activePrompt is undefined inside CommandInstance

alansouzati commented 8 years ago

In here https://github.com/dthree/vorpal/blob/master/lib/ui.js#L175

it returns because parent is undefined. This explains the silent exit