clown
Version:
clown computing with pkgcloud
21 lines (16 loc) • 488 B
JavaScript
var read = require('read');
var log = require('./log');
module.exports = function prompt(path, schema, cb) {
read({
prompt: log.heading + ' ' + path.join('.') + ' ? >'
}, function(err, res) {
if (err) return cb(err);
log.silly('prompt', 'result: `%s`', res);
switch (schema[Object.keys(schema)[0]]._type) {
case 'number':
log.silly('prompt', 'Typecasting `%s` to a number', res);
res = parseFloat(res, 10);
}
cb(null, res);
});
};