@liara/cli
Version:
The command line interface for Liara
28 lines (27 loc) • 1.01 kB
JavaScript
import { ux } from '@oclif/core';
import Command from '../../base.js';
class AccountList extends Command {
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 Current = acc[1].current ? '👍' : '';
return { Name, Email, Current };
});
ux.table(accountsData, { Name: {}, Email: {}, Current: {} }, flags);
}
}
AccountList.description = 'list available accounts';
AccountList.flags = {
...Command.flags,
...ux.table.flags(),
};
AccountList.aliases = ['account:ls'];
export default AccountList;