 		if cli.global.project?
 			changeProjectDirectory(cli.global.project)
 
-		capitano.execute cli, (error) ->
-			errors.handle(error) if error?
+		capitano.execute(cli, callback)
+
+], errors.handle)

_ = require('lodash')
path = require('path')
capitano = require('capitano')
resin = require('resin-sdk')
nplugm = require('nplugm')
actions = require('./actions')
errors = require('./errors')
plugins = require('./plugins')

	catch
		errors.handle(new Error("Invalid project: #{directory}"))

async.waterfall([

	(callback) ->
		plugins.register('resin-plugin-*', callback)

	(loadedPlugins, callback) ->
		dataPrefix = resin.settings.get('dataPrefix')
		resin.data.prefix.set(dataPrefix, callback)

	(callback) ->
		cli = capitano.parse(process.argv)

		if cli.global.quiet
			console.info = _.noop
