@shift-code/cli
Version:
Redeem Gearbox SHiFT codes automatically
47 lines • 1.59 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.accountCommand = accountCommand;
const chalk_1 = __importDefault(require("chalk"));
const table_1 = require("table");
const cache_1 = require("../cache");
async function accountCommand() {
const cache = await (0, cache_1.loadMetaCache)();
if (!cache.accounts?.length) {
console.error('No saved accounts, login to add one.');
console.info('$ shift-code login');
return;
}
const list = [
[
chalk_1.default.bold('Name'),
chalk_1.default.bold('Email'),
chalk_1.default.bold('Active')
]
];
for (const accountID of cache.accounts) {
try {
const user = await (0, cache_1.loadAccountCache)(accountID);
if (!user.account)
continue;
const isActiveAccount = typeof cache.activeAccountID === 'string'
&& cache.activeAccountID === user.account?.id;
list.push([
user.account?.name,
user.account?.email,
isActiveAccount ? chalk_1.default.green('Y') : ''
]);
}
catch { }
}
console.log((0, table_1.table)(list, {
header: {
alignment: 'left',
content: 'Saved accounts'
},
border: (0, table_1.getBorderCharacters)('norc')
}));
}
//# sourceMappingURL=account.js.map
;