+commands = {}
+for k, v of af
+ commands[k] = v unless k is 'login'
+
+# this is the friendly one that updates the files then restarts the app
+commands.app_publish = (token, app_name, zip_file, callback) ->
+ async.waterfall [
+ (callback) => @api 'app_update_files', app_name, zip_file, callback
+ (res, callback) => @api 'app_restart', app_name, callback
+ ], callback
+
+commands.app_set_state = (token, app_name, state, callback) ->
+ async.waterfall [
+ (callback) =>
+ @api 'app_info', app_name, callback
+ (info, callback) =>
+ info.state = state
+ @api 'app_set_info', app_name, info, callback
+ ], callback
+
+commands.app_start = (token, app_name, callback) ->
+ @api 'app_set_state', app_name, 'STARTED', callback
+
+commands.app_stop = (token, app_name, callback) ->
+ @api 'app_set_state', app_name, 'STOPPED', callback
+
+
+commands.app_restart = (token, app_name, callback) ->
+ # Server requires you to fetch the app state before each call to change
+ # it, so there's no quicker way than just calling app_stop then app_start
+ async.waterfall [
+ (callback) => @api 'app_stop', app_name, callback
+ (res, callback) => @api 'app_start', app_name, callback
+ ], callback
+
+
+