Implement env:rm command

This commit is contained in:
Juan Cruz Viotti 2014-11-24 13:00:36 -04:00
parent 7988b0cbbe
commit b9d5b0fd59
3 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,6 @@
_ = require('lodash')
table = require('../table/table')
patterns = require('../patterns/patterns')
log = require('../log/log')
environemtVariablesModel = require('../models/environment-variables')
authHooks = require('../hooks/auth')
@ -23,3 +24,11 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
log.out(table.horizontal(environmentVariables))
.catch (error) ->
throw error
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
patterns.remove 'environment variable', program.parent.yes, (callback) ->
environemtVariablesModel.remove(id).then ->
return callback()
.catch(callback)
, (error) ->
throw error if error?

View File

@ -122,6 +122,11 @@ program
.description('List all environment variables')
.action(env.list)
program
.command('env:rm <id>')
.description('Remove environment variable')
.action(env.remove)
data.prefix.set config.dataPrefix, (error) ->
throw error if error?
program.parse(process.argv)

View File

@ -13,3 +13,8 @@ exports.getAll = (applicationId) ->
if not environmentVariables?
return Promise.reject(new Error('Not found'))
return environmentVariables
exports.remove = (id) ->
return canvas.delete
resource: 'environment_variable'
id: id