synchro-prompt
Wrapper around readline-sync with chalk coloring for synchronous cli prompting.
Install
npm install synchro-prompt
Usage
var prompt = ; var answer = ;// $ Enter Value: HELLO!answer; // HELLO! // or as an arrayvar answers = ;// $ Name: Jane// $ Age: Doeanswers instanceof Array; // trueanswers; // ['Jane', 'Doe']
Options
By default, the prompt coloring is yellow. This can be overriden
with any valid chalk
color (provided as string), along with an optional
transformation callback which can be used to format or validate input.
var options = color: 'magenta' { return input; };; // back to the default no-transform yellow;
You can set the options from one point forward by passing the options hash as the first argument.
// prompt from here on will always use your options; ; // ie. 1426910954458_something // but you can still override a single call;// future calls without a second argument will go back to prepending a timestamp // to restore the factory defaults, call the synchro-prompt fn with no arguments; // yellow, no-transform