diff --git a/lib/forever/cli.js b/lib/forever/cli.js index 1e83e973..08b86a7e 100644 --- a/lib/forever/cli.js +++ b/lib/forever/cli.js @@ -74,6 +74,19 @@ app.use(flatiron.plugins.cli, { usage: help }); +var actions = [ + 'start', + 'stop', + 'restart', + 'list', + 'config', + 'set', + 'clear', + 'logs', + 'columns', + 'cleanlogs' +]; + var argvOptions = cli.argvOptions = { 'command': {alias: 'c'}, 'errFile': {alias: 'e'}, @@ -453,22 +466,29 @@ app.cmd('help', cli.help = function () { // Remark: this regex matches everything. It has to be added at the end to // make executing other commands possible. // -app.cmd(/(.*)/, cli.start = function () { - var file = require('optimist').argv._[0], +cli.run = function () { + var file = app.argv._[0], options = getOptions(file); + tryStart(file, options, function () { var monitor = forever.start(file, options); monitor.on('start', function () { forever.startServer(monitor); }); }); -}); +}; cli.start = function () { if (app.config.get('help')) { return util.puts(help.join('\n')); } - app.init(app.start); + app.init(function () { + if (actions.indexOf(app.argv._[0]) === -1) { + return cli.run(); + } + + app.start(); + }); };