-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathindex.js
35 lines (31 loc) · 884 Bytes
/
index.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
'use strict'
const co = require('co')
const cli = require('heroku-cli-util')
function * run (context, heroku) {
const _ = require('lodash')
let authorizations = yield heroku.get('/oauth/authorizations')
authorizations = _.sortBy(authorizations, 'description')
if (context.flags.json) {
cli.styledJSON(authorizations)
} else if (authorizations.length === 0) {
cli.log('No OAuth authorizations.')
} else {
cli.table(authorizations, {
printHeader: null,
columns: [
{key: 'description', format: v => cli.color.green(v)},
{key: 'id'},
{key: 'scope', format: v => v.join(',')}
]
})
}
}
module.exports = {
topic: 'authorizations',
description: 'list OAuth authorizations',
needsAuth: true,
flags: [
{name: 'json', char: 'j', description: 'output in json format'}
],
run: cli.command(co.wrap(run))
}