 #   Get ElasticSearch Cluster Information
 #
 # Commands:
-#   hubot: elasticsearch cluster [server] - Gets the cluster information for the given server or alias
-#   hubot: elasticsearch cat nodes [server] - Gets the information from the cat nodes endpoint for the given server or alias
-#   hubot: elasticsearch cat indexes [server] - Gets the information from the cat indexes endpoint for the given server or alias
+#   hubot: elasticsearch cluster [cluster] - Gets the cluster information for the given server or alias
+#   hubot: elasticsearch cat nodes [cluster] - Gets the information from the cat nodes endpoint for the given server or alias
+#   hubot: elasticsearch cat indexes [cluster] - Gets the information from the cat indexes endpoint for the given server or alias
+#   hubot: elasticsearch clear cache [cluster] - Clears the cache for the specified cluster
 #   hubot: elasticsearch show aliases - shows the aliases for the list of ElasticSearch instances
 #   hubot: elasticsearch add alias [alias name] [url] - sets the alias for a given url
 #   hubot: elasticsearch clear alias [alias name] - please note that this needs to include any port numbers as appropriate

          list   = [header].concat(lines.sort().reverse()).join("\n")
          msg.send("/code #{list}")

  robot.hear /elasticsearch cat nodes (.*)/i, (msg) ->
    if msg.message.user.id is robot.name
      return

    clearAlias msg, msg.match[1], (text) ->
      msg.send(text)

  robot.respond /elasticsearch clear cache (.*)/i, (msg) ->
    if msg.message.user.id is robot.name
      return

    clearCache msg, msg.match[1], (text) ->
      msg.send(text)
