From a39fee16f83011299c3fb97b3ec715ac4b199f54 Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 11 Jul 2011 01:48:19 -0400 Subject: [PATCH] [api] Began work on `forever columns *` --- bin/forever | 47 +++++++++++++++++++++++++++++----------------- lib/forever/cli.js | 12 ++++++++++-- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/bin/forever b/bin/forever index 1f526f7a..d21f6361 100755 --- a/bin/forever +++ b/bin/forever @@ -7,14 +7,15 @@ var path = require('path'), forever = require('./../lib/forever'); var action, accepts = [ + 'config', + 'cleanlogs', + 'clear', + 'columns', + 'list', 'start', 'stop', 'stopall', - 'list', - 'config', - 'clear', 'set', - 'cleanlogs', 'restart' ]; @@ -30,15 +31,17 @@ var help = [ 'Monitors the script specified in the current process or as a daemon', '', 'actions:', - ' start Start SCRIPT as a daemon', - ' stop Stop the daemon SCRIPT', - ' stopall Stop all running forever scripts', - ' restart Restart the daemon SCRIPT', - ' list List all running forever scripts', - ' config Lists all forever user configuration', - ' set Sets the specified forever config ', - ' clear Clears the specified forever config ', - ' cleanlogs [CAREFUL] Deletes all historical forever log files', + ' start Start SCRIPT as a daemon', + ' stop Stop the daemon SCRIPT', + ' stopall Stop all running forever scripts', + ' restart Restart the daemon SCRIPT', + ' list List all running forever scripts', + ' config Lists all forever user configuration', + ' set Sets the specified forever config ', + ' clear Clears the specified forever config ', + ' columns add Adds the specified column to the output in `forever list`', + ' columns rm Removed the specified column from the output in `forever list`', + ' cleanlogs [CAREFUL] Deletes all historical forever log files', '', 'options:', ' -m MAX Only run the specified script MAX times', @@ -220,12 +223,22 @@ if (argv.d || argv.debug) { forever._debug(); } -// -// If this is a set action then get the first -// value from the options and continue. -// if (action === 'set') { + // + // If this is a set action then get the first + // value from the options and continue. + // + options = options.options[0]; +} +else if (action === 'columns') { + // + // Otherwise if this is a `forever columns` + // operation then update the action, options, + // and file then continue. + // + action = [action, file]; options = options.options[0]; + file = null; } forever.cli.exec(action, file, options); diff --git a/lib/forever/cli.js b/lib/forever/cli.js index c55c79a1..3316d2c9 100644 --- a/lib/forever/cli.js +++ b/lib/forever/cli.js @@ -23,8 +23,10 @@ var reserved = ['root', 'pidPath']; // Executes the `action` in forever with the specified `file` and `options`. // cli.exec = function (action, file, options) { + var display = Array.isArray(action) ? action.join(' ') : action; + if (action) { - forever.log.info('Running action: ' + action.yellow); + forever.log.info('Running action: ' + display.yellow); } if (action === 'cleanlogs') { @@ -56,7 +58,9 @@ cli.exec = function (action, file, options) { return cli.start(file, options); } - cli[action](file, options, true); + return Array.isArray(action) + ? cli[action[0]](action[1], options) + : cli[action](file, options, true); }; // @@ -219,6 +223,10 @@ cli.clear = function (key) { }); }; +cli.columns = function (action, value) { + console.dir(arguments); +} + // // ### @private function (file, options, callback) // #### @file {string} Target script to start