Add listuser to cli

This commit is contained in:
Ethanell 2020-04-28 22:48:50 +02:00
parent c31c801f56
commit 3713240618
2 changed files with 9 additions and 1 deletions

8
cli.js
View file

@ -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;

View file

@ -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;
}