Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to wait for input? #170

Open
samgensburg opened this issue Jan 17, 2017 · 2 comments
Open

Option to wait for input? #170

samgensburg opened this issue Jan 17, 2017 · 2 comments

Comments

@samgensburg
Copy link

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?

@1fabunicorn
Copy link

anyone have any ideas? @samgensburg did you figure out a fix?

@caub
Copy link
Contributor

caub commented Mar 2, 2020

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants