-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathwhoami.ts
More file actions
25 lines (21 loc) · 929 Bytes
/
whoami.ts
File metadata and controls
25 lines (21 loc) · 929 Bytes
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
import { cliux, log, handleAndLogError, messageHandler } from '@contentstack/cli-utilities';
import { BaseCommand } from '../../base-command';
export default class WhoamiCommand extends BaseCommand<typeof WhoamiCommand> {
static description = 'Display current users email address';
static examples = ['$ csdx auth:whoami'];
static aliases = ['whoami'];
async run(): Promise<any> {
try {
if (this.email) {
cliux.print('CLI_AUTH_WHOAMI_LOGGED_IN_AS', { color: 'white' });
cliux.print(this.email, { color: 'green' });
log.info(messageHandler.parse('CLI_AUTH_WHOAMI_LOGGED_IN_AS', this.email), this.contextDetails);
} else {
log.error(messageHandler.parse('CLI_AUTH_WHOAMI_FAILED'), this.contextDetails);
}
} catch (error) {
cliux.print('CLI_AUTH_WHOAMI_FAILED', { color: 'yellow' });
handleAndLogError(error, { ...this.contextDetails });
}
}
}