Browse files

[minor] Use the `optimist` built-in argument parser instead of relyin…

…g on `commands.parse()`
  • Loading branch information...
1 parent 8a73e03 commit a8773afab571516476af2f36aaea8342e156c3c0 @indexzero indexzero committed Apr 6, 2011
Showing with 5 additions and 17 deletions.
  1. +1 −1 bin/jitsu
  2. +3 −3 lib/jitsu.js
  3. +1 −13 lib/jitsu/commands.js
View
2 bin/jitsu
@@ -8,6 +8,6 @@ var eyes = require('eyes'),
argv = require('optimist').argv,
jitsu = require('jitsu');
-jitsu.start(argv._.join(' '), function () {
+jitsu.start(argv._, function () {
winston.info('Nodejitsu'.grey + ' ok'.yellow.bold);
});
View
6 lib/jitsu.js
@@ -75,18 +75,18 @@ jitsu.start = function (command, callback) {
jitsu.exec = function (command, callback) {
if (!command) {
winston.error('No command supplied');
- return jitsu.showError(command, {}, true, true);
+ return jitsu.showError(command.join(' '), {}, true, true);
}
function execCommand (err) {
if (err) {
return callback(err);
}
- winston.info('Executing command ' + jitsu.commands.parse(command).splice(0, 2).join(' ').magenta);
+ winston.info('Executing command ' + command.join(' ').magenta);
jitsu.commands.run(command, function (err, shallow) {
if (err) {
- return jitsu.showError(command, err, shallow);
+ return jitsu.showError(command.join(' '), err, shallow);
}
//
View
14 lib/jitsu/commands.js
@@ -17,25 +17,13 @@ commands.commands = {
var requireAuth = ['apps', 'snapshots', 'logs'];
//
-// ### function parse (command)
-// #### @command {string} Command to parse
-// Parses the specified command string.
-//
-commands.parse = function (command) {
- //
- // Remark (indexzero): Do we need more parsing than this?
- //
- return command.split(' ');
-};
-
-//
// ### function run (command, callback)
// #### @command {Array} Command to run
// #### @callback {function} Continuation to pass control to when complete.
// Runs the specified command.
//
commands.run = function (command, callback) {
- var parts = commands.parse(command),
+ var parts = command.slice(0),
name = parts.shift(),
action = parts.shift(),
expected, resource;

0 comments on commit a8773af

Please sign in to comment.