Implement key list command

This commit is contained in:
Juan Cruz Viotti 2014-11-20 13:02:29 -04:00
parent a189e21c30
commit c4bb275923
3 changed files with 17 additions and 0 deletions

12
lib/actions/keys.coffee Normal file
View File

@ -0,0 +1,12 @@
server = require('../server/server')
authHooks = require('../hooks/auth')
table = require('../table/table')
config = require('../config')
exports.list = authHooks.failIfNotLoggedIn ->
server.get config.urls.keys, (error, response, keys) ->
throw error if error?
console.log table.horizontal keys, (key) ->
delete key.public_key
return key
, [ 'ID', 'Title' ]

View File

@ -32,6 +32,10 @@ yargs.command('preferences', preferences.preferences)
version = require('./actions/version')
yargs.command('version', version.version)
# ---------- Keys Module ----------
keys = require('./actions/keys')
yargs.command('keys', keys.list)
data.prefix.set config.dataPrefix, (error) ->
throw error if error?
yargs.command.run()

View File

@ -15,6 +15,7 @@ config =
config.urls =
signup: '/signup'
preferences: '/preferences'
keys: '/user/keys'
# Append config.remoteUrl before every url
config.urls = _.object _.map config.urls, (value, key, object) ->