mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 22:47:48 +00:00
30 lines
920 B
CoffeeScript
30 lines
920 B
CoffeeScript
_ = require('lodash')
|
|
resin = require('../resin')
|
|
cli = require('../cli/cli')
|
|
ui = require('../ui')
|
|
|
|
SYSTEM_VAR_REGEX = /^RESIN_/
|
|
|
|
isSystemVariable = (environmentVariable) ->
|
|
SYSTEM_VAR_REGEX.test(environmentVariable.name)
|
|
|
|
exports.list = ->
|
|
applicationId = cli.getArgument('application')
|
|
|
|
if not applicationId?
|
|
resin.errors.handle(new Error('You have to specify an application'))
|
|
|
|
resin.models.environmentVariables.getAll applicationId, (error, environmentVariables) ->
|
|
resin.errors.handle(error) if error?
|
|
|
|
if not cli.getArgument('verbose')?
|
|
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
|
|
|
resin.log.out(ui.widgets.table.horizontal(environmentVariables))
|
|
|
|
exports.remove = (id) ->
|
|
confirmArgument = cli.getArgument('yes')
|
|
ui.patterns.remove 'environment variable', confirmArgument, (callback) ->
|
|
resin.models.environmentVariables.remove(id, callback)
|
|
, resin.errors.handle
|