This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
get.js
48 lines (42 loc) · 1.42 KB
/
get.js
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
43
44
45
46
47
48
const {flags} = require('@oclif/command');
const BaseCommand = require('../../base');
class ActionsGetCommand extends BaseCommand {
async run() {
const {flags} = this.parse(ActionsGetCommand);
const {isTTY} = process.stdout;
const {api, styledJSON, spinner} = this;
const {json} = flags;
let {id} = flags;
if (!id && isTTY) {
const {askID} = require('../../prompts');
const {actionID} = await askID('action');
id = actionID;
}
try {
spinner.start('Loading action...');
const {body} = await api.accountGetAction(id);
spinner.stop();
if (json) {
this.log(styledJSON(body));
} else {
const {action} = body;
this.log('ID:', action.id);
this.log('Status:', action.status);
this.log('Type:', action.type);
this.log('Started At:', new Date(action.started_at).toUTCString());
this.log('Completed At:', new Date(action.completed_at).toUTCString());
this.log('Resource ID:', action.resource_id);
this.log('Region:', action.region.name);
}
} catch (error) {
spinner.stop();
this.error(error.message);
}
}
}
ActionsGetCommand.description = 'get details about a specific action';
ActionsGetCommand.flags = {
id: flags.integer({char: 'i', description: 'pass the action id'}),
json: flags.boolean({description: 'output in json format'})
};
module.exports = ActionsGetCommand;