Skip to content

Commit

Permalink
[api] Began work on forever columns *
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jul 11, 2011
1 parent 381ecaf commit a39fee1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
47 changes: 30 additions & 17 deletions bin/forever
Expand Up @@ -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'
];

Expand All @@ -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 <key> <val> Sets the specified forever config <key>',
' clear <key> Clears the specified forever config <key>',
' 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 <key> <val> Sets the specified forever config <key>',
' clear <key> Clears the specified forever config <key>',
' columns add <col> Adds the specified column to the output in `forever list`',
' columns rm <col> 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',
Expand Down Expand Up @@ -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);
12 changes: 10 additions & 2 deletions lib/forever/cli.js
Expand Up @@ -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') {
Expand Down Expand Up @@ -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);
};

//
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a39fee1

Please sign in to comment.