syncprompt
A real sync-prompt solution for node.
What is this?
Python users have always add a simple easy way to grab user-input:
foo = input()
while us JavaScript users are stuck with:
processstdinprocessstdin;
but those days are long over! This brings an elegant prompt function to node.
Well they are other sync-prompt libraries? Hardly, here are the two:
- sync-prompt, not maintained, doesn't even work on most versions of node anymore
- prompt-sync, very flimsy, doesn't properly handle mixed stdin modes, and lacks proper support for more complex stdin reading. Attempts to mimick terminal inputs with raw-mode but breaks easily
So here's a real solution, one that actually mimicks a getline
or input
function (uses getline()
internally).
Installation
This is easy. Install using:
$ npm install --save syncprompt
Now, in your project, just do:
var prompt = ;
or, if you're using the fancy new import
syntax:
;
Usage
Usage couldn't be more simple. Simple do:
var name = ;
Passwords? simply add secure: true
and you'll get a real hidden password prompt:
var passwords = ;
Examples
A full example is the following:
var prompt = ; var username = ;var password = ; console;