Implement key:rm command

This commit is contained in:
Juan Cruz Viotti 2014-11-21 13:56:11 -04:00
parent 832cbf89ff
commit 29054bedf1
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@ _ = require('lodash')
server = require('../server/server')
authHooks = require('../hooks/auth')
log = require('../log/log')
patterns = require('../patterns/patterns')
table = require('../table/table')
helpers = require('../helpers/helpers')
keyModel = require('../models/key')
@ -29,3 +30,9 @@ exports.info = authHooks.failIfNotLoggedIn (id) ->
key.public_key = '\n' + helpers.formatLongString(key.public_key, config.sshKeyWidth)
log.out(table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
patterns.remove 'key', program.parent.yes, (callback) ->
server.delete("/user/keys/#{id}", callback)
, (error) ->
throw error if error?

View File

@ -92,6 +92,11 @@ program
.description('List a single SSH key')
.action(keys.info)
program
.command('key:rm <id>')
.description('Remove a SSH key')
.action(keys.remove)
data.prefix.set config.dataPrefix, (error) ->
throw error if error?
program.parse(process.argv)