From 371324061810ed92ffdaaa1a21ffb88cdbc0bab2 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 28 Apr 2020 22:48:50 +0200 Subject: [PATCH] Add listuser to cli --- cli.js | 8 ++++++++ user.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cli.js b/cli.js index e1a0f4a..608a23f 100644 --- a/cli.js +++ b/cli.js @@ -30,6 +30,14 @@ yargs.scriptName("node cli.js") }, async (argv) => { process.exit(user.delUser(argv.username)); }) + .command("listuser", "List all users", (argv) => { + let users = []; + let file = user.getFile(); + for (let u in file) + users.push(u); + console.log("Users: " + users.join(", ")); + process.exit(0); + }) .help() .alias("h", "help") .argv; diff --git a/user.js b/user.js index 600f567..c9128be 100644 --- a/user.js +++ b/user.js @@ -24,7 +24,7 @@ async function getUsername() { while (true) { username = await new Promise(resolve => rl.question("Username: ", resolve)); if (username in file || ["", null].indexOf(username) >= 0) - console.error("Invalid username !") + console.error("Invalid username !"); else break; }