Spaces:
Runtime error
Runtime error
File size: 1,256 Bytes
4a51346 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
'use strict';
const utils = require('./utils');
const roles = {
default(prompt, choice) {
return choice;
},
checkbox(prompt, choice) {
throw new Error('checkbox role is not implemented yet');
},
editable(prompt, choice) {
throw new Error('editable role is not implemented yet');
},
expandable(prompt, choice) {
throw new Error('expandable role is not implemented yet');
},
heading(prompt, choice) {
choice.disabled = '';
choice.indicator = [choice.indicator, ' '].find(v => v != null);
choice.message = choice.message || '';
return choice;
},
input(prompt, choice) {
throw new Error('input role is not implemented yet');
},
option(prompt, choice) {
return roles.default(prompt, choice);
},
radio(prompt, choice) {
throw new Error('radio role is not implemented yet');
},
separator(prompt, choice) {
choice.disabled = '';
choice.indicator = [choice.indicator, ' '].find(v => v != null);
choice.message = choice.message || prompt.symbols.line.repeat(5);
return choice;
},
spacer(prompt, choice) {
return choice;
}
};
module.exports = (name, options = {}) => {
let role = utils.merge({}, roles, options.roles);
return role[name] || role.default;
};
|