This repository was 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
/
Copy pathget.js
49 lines (43 loc) · 1.5 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
49
const {flags} = require('@oclif/command');
const BaseCommand = require('../../base');
class SnapshotsGetCommand extends BaseCommand {
async run() {
const {flags} = this.parse(SnapshotsGetCommand);
const {isTTY} = process.stdout;
const {api, styledJSON, spinner} = this;
const {json} = flags;
let {id} = flags;
if (!id && isTTY) {
const {askID} = require('../../prompts');
const {snapshotID} = await askID('snapshot');
id = snapshotID;
}
try {
spinner.start('Loading action...');
const {body} = await api.snapshotsGetById(id);
spinner.stop();
if (json) {
this.log(styledJSON(body));
} else {
const {snapshot} = body;
this.log('ID:', snapshot.id);
this.log('Name:', snapshot.name);
this.log('Size Gigabytes:', snapshot.size_gigabytes);
this.log('Min disk size:', snapshot.min_disk_size);
this.log('Created At:', new Date(snapshot.completed_at).toUTCString());
this.log('Resource Type:', snapshot.resource_type);
this.log('Resource ID:', snapshot.resource_id);
this.log('Regions:', snapshot.regions);
}
} catch (error) {
spinner.stop();
this.error(error.message);
}
}
}
SnapshotsGetCommand.description = `get details about a snapshot`;
SnapshotsGetCommand.flags = {
id: flags.integer({char: 'i', description: 'pass the action id'}),
json: flags.boolean({description: 'output in json format'})
};
module.exports = SnapshotsGetCommand;