/
list.ts
42 lines (35 loc) · 1.01 KB
/
list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { ux } from '@oclif/core';
import Command from '../../base.js';
export default class AccountList extends Command {
static description = 'list available accounts';
static flags = {
...Command.flags,
...ux.table.flags(),
};
static aliases = ['account:ls'];
async run() {
const { flags } = await this.parse(AccountList);
const liara_json = await this.readGlobalConfig();
if (
!liara_json ||
!liara_json.accounts ||
Object.keys(liara_json.accounts).length === 0
) {
this.error(
"Please add your accounts via 'liara account:add' command, first."
);
}
const accountsData = Object.entries(liara_json.accounts).map((acc) => {
const Name = acc[0];
const Email = acc[1].email;
const Region = acc[1].region;
const Current = acc[1].current ? '👍' : '';
return { Name, Email, Region, Current };
});
ux.table(
accountsData,
{ Name: {}, Email: {}, Region: {}, Current: {} },
flags
);
}
}