balena-cli
Version:
The official balena Command Line Interface
46 lines (45 loc) • 1.86 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const lazy_1 = require("../../utils/lazy");
class WhoamiCmd extends core_1.Command {
async run() {
await this.parse(WhoamiCmd);
const balena = (0, lazy_1.getBalenaSdk)();
const [whoamiResult, url] = await Promise.all([
balena.auth.whoami(),
balena.settings.get('balenaUrl'),
]);
if ((whoamiResult === null || whoamiResult === void 0 ? void 0 : whoamiResult.actorType) === 'user') {
const { username, email } = whoamiResult;
console.log((0, lazy_1.getVisuals)().table.vertical({ username, email, url }, [
'$account information$',
'username',
'email',
'url',
]));
}
else if ((whoamiResult === null || whoamiResult === void 0 ? void 0 : whoamiResult.actorType) === 'device') {
console.log((0, lazy_1.getVisuals)().table.vertical({ device: whoamiResult.uuid, url }, [
'$account information$',
'device',
'url',
]));
}
else if ((whoamiResult === null || whoamiResult === void 0 ? void 0 : whoamiResult.actorType) === 'application') {
console.log((0, lazy_1.getVisuals)().table.vertical({ application: whoamiResult.slug, url }, [
'$account information$',
'application',
'url',
]));
}
}
}
WhoamiCmd.description = (0, lazy_1.stripIndent) `
Display account information for current user.
Get the username and email address of the currently logged in user.
`;
WhoamiCmd.examples = ['$ balena whoami'];
WhoamiCmd.authenticated = true;
exports.default = WhoamiCmd;
//# sourceMappingURL=index.js.map
;