-
Notifications
You must be signed in to change notification settings - Fork 221
/
index.ts
31 lines (28 loc) · 1.04 KB
/
index.ts
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
import color from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import ux from 'cli-ux'
import * as _ from 'lodash'
import {quote} from '../../quote'
export class ConfigIndex extends Command {
static description = 'display the config vars for an app'
static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
shell: flags.boolean({char: 's', description: 'output config vars in shell format'}),
json: flags.boolean({char: 'j', description: 'output config vars in json format'}),
}
async run() {
const {flags} = this.parse(ConfigIndex)
const {body: config} = await this.heroku.get<Heroku.ConfigVars>(`/apps/${flags.app}/config-vars`)
if (flags.shell) {
Object.entries(config)
.forEach(([k, v]) => ux.log(`${k}=${quote(v)}`))
} else if (flags.json) {
ux.styledJSON(config)
} else {
ux.styledHeader(`${flags.app} Config Vars`)
ux.styledObject(_.mapKeys(config, (_, k) => color.configVar(k)))
}
}
}