1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function displayJSON (peerings) {
|
7 | cli.log(JSON.stringify(peerings, null, 2))
|
8 | }
|
9 |
|
10 | function * run (context, heroku) {
|
11 | let lib = require('../../lib/peering')(heroku)
|
12 | let space = context.flags.space || context.args.space
|
13 | if (!space) throw new Error('Space name required.\nUSAGE: heroku spaces:peerings --space my-space')
|
14 | let peers = yield lib.getPeerings(space)
|
15 | if (context.flags.json) displayJSON(peers)
|
16 | else lib.displayPeers(space, peers)
|
17 | }
|
18 |
|
19 | module.exports = {
|
20 | topic: 'spaces',
|
21 | command: 'peerings',
|
22 | description: 'list peering connections for a space',
|
23 | needsApp: false,
|
24 | needsAuth: true,
|
25 | args: [{name: 'space', optional: true, hidden: true}],
|
26 | flags: [
|
27 | {name: 'space', char: 's', hasValue: true, description: 'space to get peer list from'},
|
28 | {name: 'json', description: 'output in json format'}
|
29 | ],
|
30 | run: cli.command(co.wrap(run))
|
31 | }
|