Option to wait for input?
samgensburg opened this issue · comments
Sam Gensburg commented
I'm currently creating a simple command-line application that takes in a series (potentially infinite) of commands, and responds to each one at a time. I'd like this to look a bit like this:
prompt.start();
while(true) {
result = prompt.getSync();
if (result.command == 'quit') { exit(1); }
// do something with result
}
Would it be possible to create a version of result.get that would hold execution until a result is returned?
Nova Trauben commented
anyone have any ideas? @samgensburg did you figure out a fix?
Cyril Auburtin commented
const prompt = require('prompt');
const getPrompt = require('util').promisify(prompt.get).bind(prompt);
(async function () {
const { foo, bar } = await getPrompt({
properties: {
foo: {
description: 'Foo',
// ...
}
});
})()
now Ideally this lib should work with promises,