const db = require("../lib/db") const yargs = require("yargs") const libIlias = require("../lib/libIlias") const search = require("../lib/search") ///////////////////////////////////////////////////////////////////////// const argv = yargs .usage("$0 ", "delete user ",) .strict() .parse() console.log(`argv.ref_id=${argv.ref_id}`) run(argv) .then(console.log) .catch(console.error) .finally(process.exit) async function run ({login}) { let userIds = await search.search(String(login)) if (userIds.length > 1) throw {msg: "result not distinct!", results: userIds} if (userIds.length === 0) throw {msg: "nothing found!", results: userIds} const usr_id = userIds[0] const user = await db.getUserByUserId(usr_id) console.log(user) const { Confirm } = require('enquirer'); const prompt = new Confirm({ name: 'question', message: `Delete user ${user.firstname} ${user.lastname} (${user.usr_id})`, }); const doContinue = await prompt.run(); if(doContinue) { return libIlias.deleteUser(usr_id) } else { return "nothing changed... bye bye!" } }