exchangemarket/setup/getInput.js
sairajzero 96b9d3b6e9 Setup files
- Adding setup files to configure, set password.
- Private key will now be stored in encrypted shares. Password will be required for running the server.
- Automated creation of MySQL schema.
- Making floGlobals common for both server and client.
- Fixed a minor bug in database.js
2021-09-29 04:14:02 +05:30

42 lines
1.5 KiB
JavaScript

const readline = require('readline');
const getInput = {
Text: function(text, current = null) {
return new Promise((resolve) => {
let r = readline.createInterface({
input: process.stdin,
output: process.stdout
});
r.question(`${text} :` + (current ? `(${current})` : ''), value => {
r.close();
value = value || current;
if (value === null) {
console.log("Please enter a value!");
this.Text(text, current).then(result => resolve(result));
} else
resolve(value);
});
})
},
YesOrNo: function(text, def_value = "YES") {
return new Promise((resolve) => {
let r = readline.createInterface({
input: process.stdin,
output: process.stdout
});
r.question(`${text}? [YES/NO] : (${def_value})`, value => {
r.close();
value = (value || def_value).toLowerCase();
value = ['yes', 'y'].includes(value) ? true : ['no', 'n'].includes(value) ? false : null;
if (value === null) {
console.log("Please enter a valid value!");
this.YesOrNo(text, def_value).then(result => resolve(result));
} else
resolve(value);
});
})
}
}
module.exports = getInput;