Permalink
Browse files

[dist] help command actually works now

  • Loading branch information...
1 parent 5215aef commit 074f29690aa816d66810b9b72130c758d0e75406 @alejandro alejandro committed Jun 28, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/commands.js
View
18 lib/commands.js
@@ -78,9 +78,9 @@ var commands = {
help: {
usage: function(args) {
if (args && args[0] && args[0].toLowerCase() === 'all') {
- showUsage();
+ showUsage();
} else {
- showHelp(args);
+ showHelp(args);
}
}
},
@@ -123,6 +123,7 @@ function run (cmds, command) {
function tail (args){
if(log.inTest){
// mocha args
+
args.pop();
args.pop();
}
@@ -147,12 +148,17 @@ function run (cmds, command) {
cmds[command].run(tail(process.argv.slice(1)) || 'usage');
} else {
var args = tail(process.argv.slice(1));
- if (args.length){
+
+ if (args.length && !cmds[args]){
log.warn('Run > nodester '+ command + ' usage ');
log.error('command not found: ' + args);
} else if (!log.inTest) {
- log.info(command, 'usage:');
- cmds[command] && cmds[command].usage && cmds[command].usage();
+ if (command == 'help' && args){
+ return cmds.help.usage(args)
+ } else {
+ log.info(command, 'usage:');
+ cmds[command] && cmds[command].usage && cmds[command].usage();
+ }
} else {
log.info('Dieing cleanly');
}
@@ -167,7 +173,7 @@ function showHelp (args) {
var cmds = commands;
if (args && cmds[args[0]] && (cmds[args[0]].usage || cmds[args[0]].run)) {
- cmds[args[0]].usage();
+ cmds[args[0]].usage() || (cmds[args[0]].run && cmds[args[0]].run());
} else {
log.info('');
log.info(' \t\t\tNodester'.bold.yellow);

0 comments on commit 074f296

Please sign in to comment.