UNPKG

774 BJavaScriptView Raw
1'use strict';
2
3let co = require('co');
4let cli = require('heroku-cli-util');
5
6function* run (context, heroku) {
7 let authorizations = yield heroku.get('/oauth/authorizations');
8
9 if (context.flags.json) {
10 cli.log(JSON.stringify(authorizations, null, 2));
11 } else if (authorizations.length === 0) {
12 cli.log('No OAuth authorizations.');
13 } else {
14 cli.table(authorizations, {
15 printHeader: null,
16 columns: [
17 {key: 'description'},
18 {key: 'id'},
19 {key: 'scope', format: v => v.join(',')},
20 ]
21 });
22 }
23}
24
25module.exports = {
26 topic: 'authorizations',
27 description: 'list OAuth authorizations',
28 needsAuth: true,
29 flags: [
30 {name: 'json', description: 'output in json format'}
31 ],
32 run: cli.command(co.wrap(run))
33};