console-prompt
v1.0.0
Published
Prompt for input at the console
Downloads
12
Readme
Console prompt
Prompts the user for information at the console in a nodejs programme.
Returns a Promise.
var prompt = require('console-prompt');
prompt( 'password\n> ', 'hidden' )
.then( function(value) {
console.log( "You've entered password", value );
} );
prompt
takes two parameters:
message
- String - text to display on the screenhidden
- Truthy - if truthy the user's input is replaced with stars.
Installation
$ npm install console-prompt
Issues
Pasting
The code reacts badly to \n
, and possibly many other characters, being pasted in.
Avoid.
Windows
In Windows, backspacing in a hidden field won't update on screen correctly unless you are using a terminal supporting ANSI escape sequences.
It should still collect the correct information, though.