diff --git a/heroku.coffee b/heroku.coffee index e9debc0..061c36e 100644 --- a/heroku.coffee +++ b/heroku.coffee @@ -14,6 +14,7 @@ # hubot heroku config - Display the config vars for an app # hubot heroku config:set = - Set a config var for an app # hubot heroku config:unset - Delete a config var for an app +# hubot heroku ps - List running Heroku processes for an app heroku = new (require("heroku")).Heroku({key: process.env.HUBOT_HEROKU_API_KEY}) nodelog = (error, result)-> @@ -27,6 +28,11 @@ nodelog = (error, result)-> module.exports = (robot)-> + ### + # + # heroku config + # + ### robot.respond /heroku (.*) config:set (.*)=(.*)/i, configSet robot.respond /heroku (.*) config:add (.*)=(.*)/i, configSet configSet = (msg)-> @@ -50,4 +56,33 @@ module.exports = (robot)-> output = [] for key, value of result output.push "#{key}: #{value}" - msg.send output.join("\n") \ No newline at end of file + msg.send output.join("\n") + + ### + # + # herok ps + # + ### + robot.respond /heroku (.*) ps$/i, (msg)-> + heroku.get_ps msg.match[1], (error, result)-> + nodelog error, result + processes = {} + + for p in result + processes[p.process.split('.')[0]] ?= + command: p.command + processes: [] + + processes[p.process.split('.')[0]].processes.push [ + "#{p.process}: #{p.state}" + p.transitioned_at.split(' ')[0] + p.transitioned_at.split(' ')[1] + "(~ #{p.pretty_state.split(' ')[2]} ago)" + ].join ' ' + output = [] + for k, v of processes + output.push "== #{k}: `#{v.command}`" + for p in v.processes + output.push p + output.push '' + msg.send output.join "\n"