dthree / vorpal

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

Refresh delimiter on no command (just hit Enter) #204

Closed jstrika closed 7 years ago

jstrika commented 7 years ago

Hi,

It might be one of the questions already asked, but could not find the answer.

How to capture dialog without any arguments? I tried with parse and catch, but its not triggered on event without any arguments.

Why I need it? I'm using delimiter to represent the status of my app, which can also be changed using web interface. So I would like to refresh prompt on RETURN

MatthieuLemoine commented 7 years ago

You can update the delimiter using

vorpal.ui.delimiter('delimiter');

If you want to update it on Enter press you can add a keypress listener to process.stdin:

process.stdin.on('keypress', (_, key) => {
  if (key && key.name === 'return') {
    vorpal.ui.delimiter(newValue);
  }
});
jstrika commented 7 years ago

Great, works as advertised.

Thanks!