Just showing the error thrown by OptionParser rather than parsing it

This commit is contained in:
Trevor Burnham
2011-11-13 16:20:51 -05:00
parent 266d97f8f5
commit 73acfa18a3
2 changed files with 9 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
(function() {
var CoffeeScript, badArgument, cakefileDirectory, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
fs = require('fs');
@@ -53,7 +53,7 @@
try {
options = oparse.parse(args);
} catch (e) {
return badArgument(("" + e).match(/option: (.+)/)[1], "option");
return fatalError("" + e);
}
_ref = options.arguments;
_results = [];
@@ -78,14 +78,14 @@
if (switches.length) return console.log(oparse.help());
};
badArgument = function(arg, type) {
console.error("No such " + type + ": \"" + arg + "\"\n");
fatalError = function(message) {
console.error(message + '\n');
console.log('To see a list of all tasks/options, run "cake"');
return process.exit(1);
};
missingTask = function(task) {
return badArgument(task, "task");
return fatalError("No such task: " + task);
};
cakefileDirectory = function(dir) {

View File

@@ -53,7 +53,7 @@ exports.run = ->
try
options = oparse.parse(args)
catch e
return badArgument "#{e}".match(/option: (.+)/)[1], "option"
return fatalError "#{e}"
invoke arg for arg in options.arguments
# Display the list of Cake tasks in a format similar to `rake -T`
@@ -68,12 +68,12 @@ printTasks = ->
console.log oparse.help() if switches.length
# Print an error and exit when attempting to use an invalid task/option.
badArgument = (arg, type) ->
console.error """No such #{type}: "#{arg}"\n"""
fatalError = (message) ->
console.error message + '\n'
console.log 'To see a list of all tasks/options, run "cake"'
process.exit 1
missingTask = (task) -> badArgument task, "task"
missingTask = (task) -> fatalError "No such task: #{task}"
# When `cake` is invoked, search in the current and all parent directories
# to find the relevant Cakefile.