From 7988b0cbbe4f00a1bd18c2f8bd7101f747b12213 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 24 Nov 2014 12:43:37 -0400 Subject: [PATCH] Allow increasing verbosity for envs command --- lib/actions/environment-variables.coffee | 9 +++++++++ lib/app.coffee | 3 ++- lib/models/environment-variables.coffee | 9 +-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/actions/environment-variables.coffee b/lib/actions/environment-variables.coffee index 96901190..c98a213e 100644 --- a/lib/actions/environment-variables.coffee +++ b/lib/actions/environment-variables.coffee @@ -4,6 +4,11 @@ log = require('../log/log') environemtVariablesModel = require('../models/environment-variables') authHooks = require('../hooks/auth') +SYSTEM_VAR_REGEX = /^RESIN_/ + +isSystemVariable = (environmentVariable) -> + SYSTEM_VAR_REGEX.test(environmentVariable.name) + exports.list = authHooks.failIfNotLoggedIn (program) -> applicationId = program.parent.application @@ -11,6 +16,10 @@ exports.list = authHooks.failIfNotLoggedIn (program) -> throw new Error('You have to specify an application') environemtVariablesModel.getAll(applicationId).then (environmentVariables) -> + + if not program.parent.verbose? + environmentVariables = _.reject(environmentVariables, isSystemVariable) + log.out(table.horizontal(environmentVariables)) .catch (error) -> throw error diff --git a/lib/app.coffee b/lib/app.coffee index 0cda4a24..5143b2a8 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -8,7 +8,8 @@ program = require('commander') program.version(packageJSON.version) # ---------- Options ---------- -program.option('-y, --yes', 'Confirm non interactively') +program.option('-y, --yes', 'confirm non interactively') +program.option('-v, --verbose', 'increase verbosity') program.option('-q, --quiet', 'quiet (no output)') program.option('-t, --type ', 'specify a type when creating an application') diff --git a/lib/models/environment-variables.coffee b/lib/models/environment-variables.coffee index 0ee88752..fc158cb8 100644 --- a/lib/models/environment-variables.coffee +++ b/lib/models/environment-variables.coffee @@ -1,12 +1,6 @@ -_ = require('lodash') Promise = require('bluebird') canvas = require('./_canvas') -SYSTEM_VAR_REGEX = /^RESIN_/ - -isSystemVariable = (environmentVariable) -> - SYSTEM_VAR_REGEX.test(environmentVariable.name) - exports.getAll = (applicationId) -> return canvas.get resource: 'environment_variable' @@ -18,5 +12,4 @@ exports.getAll = (applicationId) -> .then (environmentVariables) => if not environmentVariables? return Promise.reject(new Error('Not found')) - - return _.reject(environmentVariables, isSystemVariable) + return environmentVariables