# Description:
#   Inspect the data in redis easily
#
# Commands:
#   hubot show users - Display all users that hubot knows about
#   hubot show user <user_name> - Display the information hubot knows about <user_name>
#   hubot show me - Display the information hubot knows about you
#   hubot show storage - Display the contents that are persisted in the brain


Util = require "util"

module.exports = (robot) ->
  robot.respond /show storage$/i, (msg) ->
    output = Util.inspect(robot.brain.data, false, 4)
    msg.send output

  robot.respond /show users$/i, (msg) ->
    response = ""

    for own key, user of robot.brain.data.users
      response += "#{user.id} #{user.name}"
      response += " <#{user.email_address}>" if user.email_address
      response += "\n"

    msg.send response

  robot.respond /show user (.*)/i, (msg) ->
    user = robot.brain.userForName(msg.match[1])
    msg.send Util.inspect(user, {depth: null})

  robot.respond /show me$/i, (msg) ->
    msg.send Util.inspect(msg.message.user, {depth: null})
