Skip to content
Snippets Groups Projects
Commit 375b7874 authored by kelly.nguyen's avatar kelly.nguyen
Browse files

display data with table - user list

parent 82331276
No related branches found
No related tags found
No related merge requests found
Pipeline #29953 failed
......@@ -2,8 +2,8 @@ import chalk from "chalk";
import CommanderCommand from "../../CommanderCommand";
import DojoBackendManager from "../../../managers/DojoBackendManager";
import User from "../../../sharedByClients/models/User";
import ora from "ora";
import SessionManager from "../../../managers/SessionManager";
import Table from 'cli-table3';
class UserListCommand extends CommanderCommand {
protected commandName : string = 'list';
......@@ -33,21 +33,25 @@ class UserListCommand extends CommanderCommand {
// Retrieve data
{
// TODO : display data in table
users = await DojoBackendManager.getAllUsers();
users.forEach(user => {
const oraInfo = (message: string) => {
ora({
text: message,
indent: 4
}).start().info();
};
oraInfo(`${chalk.magenta('Id:')} ${user.id}`);
oraInfo(`${chalk.magenta('Mail:')} ${user.gitlabUsername}`);
oraInfo(`${chalk.magenta('Role:')} ${user.role}`);
});
if (!users) {
return;
}
this.display(users);
}
}
private display(u : User[]) {
const table = new Table({
head: ['Id', 'Mail', 'Role']
});
u.forEach(user => {
table.push([user.id, user.gitlabUsername, user.role]);
});
console.log(table.toString());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment