Add listuser to cli
This commit is contained in:
parent
c31c801f56
commit
3713240618
2 changed files with 9 additions and 1 deletions
8
cli.js
8
cli.js
|
@ -30,6 +30,14 @@ yargs.scriptName("node cli.js")
|
||||||
}, async (argv) => {
|
}, async (argv) => {
|
||||||
process.exit(user.delUser(argv.username));
|
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()
|
.help()
|
||||||
.alias("h", "help")
|
.alias("h", "help")
|
||||||
.argv;
|
.argv;
|
||||||
|
|
2
user.js
2
user.js
|
@ -24,7 +24,7 @@ async function getUsername() {
|
||||||
while (true) {
|
while (true) {
|
||||||
username = await new Promise(resolve => rl.question("Username: ", resolve));
|
username = await new Promise(resolve => rl.question("Username: ", resolve));
|
||||||
if (username in file || ["", null].indexOf(username) >= 0)
|
if (username in file || ["", null].indexOf(username) >= 0)
|
||||||
console.error("Invalid username !")
|
console.error("Invalid username !");
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue