Package Exports
- prompt-promise
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prompt-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Sane CLI user-input (command prompt, confirm, multiline, password) as promises, it can be used with co@4
Install
npm i --save prompt-promise
Run examples
npm run with-co
npm run without-co
Usage
For more use-cases see examples
var co = require('co');
var prompt = require('prompt-promise');
var res = [];
prompt('username: ')
.then(function username(val) {
res.push(val);
return prompt.password('password: ');
})
.then(function pasword(val) {
res.push(val);
console.log(res);
prompt.done();
})
.catch(function rejected(err) {
console.log('error:', err.stack);
prompt.finish();
});
// or with `co@4`
co(function * genPrompt() {
var username = yield prompt('username: ');
var password = yield prompt.password('password: ');
return yield [username, password];
})
.then(function fulfilled(array) {
console.log('response:', array);
prompt.end();
})
.catch(function rejected(err) {
console.log('error:', err.stack);
process.stdin.pause();
});
.end()
, .done()
, .finish()
are just aliases for process.stdin.pause();
its required, nah..
Author
Charlike Mike Reagent
License 
Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Copyright (c) 2014 TJ Holowaychuk, contributors.
Released under the MIT
license.
Powered and automated by kdf, January 31, 2015