Adding 'No such option' output to parallel 'No such task' (fixes #1862)
This commit is contained in:
parent
5bf8b422f8
commit
1d7a3b4d0f
|
@ -1,5 +1,5 @@
|
||||||
(function() {
|
(function() {
|
||||||
var CoffeeScript, cakefileDirectory, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
var CoffeeScript, cakefileDirectory, fs, helpers, missingOption, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
||||||
|
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
|
|
||||||
|
@ -50,7 +50,12 @@
|
||||||
});
|
});
|
||||||
oparse = new optparse.OptionParser(switches);
|
oparse = new optparse.OptionParser(switches);
|
||||||
if (!args.length) return printTasks();
|
if (!args.length) return printTasks();
|
||||||
|
console.log(args);
|
||||||
|
try {
|
||||||
options = oparse.parse(args);
|
options = oparse.parse(args);
|
||||||
|
} catch (e) {
|
||||||
|
return missingOption(("" + e).match(/option: (.+)/)[1]);
|
||||||
|
}
|
||||||
_ref = options.arguments;
|
_ref = options.arguments;
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
@ -73,6 +78,11 @@
|
||||||
if (switches.length) return console.log(oparse.help());
|
if (switches.length) return console.log(oparse.help());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
missingOption = function(option) {
|
||||||
|
console.log("No such option: \"" + option + "\"");
|
||||||
|
return process.exit(1);
|
||||||
|
};
|
||||||
|
|
||||||
missingTask = function(task) {
|
missingTask = function(task) {
|
||||||
console.log("No such task: \"" + task + "\"");
|
console.log("No such task: \"" + task + "\"");
|
||||||
return process.exit(1);
|
return process.exit(1);
|
||||||
|
|
|
@ -50,7 +50,11 @@ exports.run = ->
|
||||||
CoffeeScript.run fs.readFileSync('Cakefile').toString(), filename: 'Cakefile'
|
CoffeeScript.run fs.readFileSync('Cakefile').toString(), filename: 'Cakefile'
|
||||||
oparse = new optparse.OptionParser switches
|
oparse = new optparse.OptionParser switches
|
||||||
return printTasks() unless args.length
|
return printTasks() unless args.length
|
||||||
|
console.log args
|
||||||
|
try
|
||||||
options = oparse.parse(args)
|
options = oparse.parse(args)
|
||||||
|
catch e
|
||||||
|
return missingOption "#{e}".match(/option: (.+)/)[1]
|
||||||
invoke arg for arg in options.arguments
|
invoke arg for arg in options.arguments
|
||||||
|
|
||||||
# Display the list of Cake tasks in a format similar to `rake -T`
|
# Display the list of Cake tasks in a format similar to `rake -T`
|
||||||
|
@ -63,6 +67,11 @@ printTasks = ->
|
||||||
console.log "cake #{name}#{spaces} #{desc}"
|
console.log "cake #{name}#{spaces} #{desc}"
|
||||||
console.log oparse.help() if switches.length
|
console.log oparse.help() if switches.length
|
||||||
|
|
||||||
|
# Print an error and exit when attempting to use an invalid option.
|
||||||
|
missingOption = (option) ->
|
||||||
|
console.log "No such option: \"#{option}\""
|
||||||
|
process.exit 1
|
||||||
|
|
||||||
# Print an error and exit when attempting to call an undefined task.
|
# Print an error and exit when attempting to call an undefined task.
|
||||||
missingTask = (task) ->
|
missingTask = (task) ->
|
||||||
console.log "No such task: \"#{task}\""
|
console.log "No such task: \"#{task}\""
|
||||||
|
|
Loading…
Reference in New Issue