diff --git a/lib/cake.js b/lib/cake.js index 058f0081..8e5e98f9 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -20,9 +20,15 @@ oparse = null; // Mixin the top-level Cake functions for Cakefiles to use directly. helpers.extend(global, { - // Define a Cake task with a short name, a sentence description, + // Define a Cake task with a short name, an optional sentence description, // and the function to run as the action itself. task: function task(name, description, action) { + var _a; + if (!((typeof action !== "undefined" && action !== null))) { + _a = [description, action]; + action = _a[0]; + description = _a[1]; + } tasks[name] = { name: name, description: description, @@ -72,7 +78,7 @@ }; // Display the list of Cake tasks in a format similar to `rake -T` print_tasks = function print_tasks() { - var _a, _b, _c, _d, _e, _f, i, name, spaces, task; + var _a, _b, _c, _d, _e, _f, _g, i, name, spaces, task; puts(''); _a = tasks; for (name in _a) { if (__hasProp.call(_a, name)) { @@ -85,7 +91,11 @@ } return _b; }).call(this).join('') : ''; - puts("cake " + name + spaces + " # " + (task.description)); + print("cake " + name + spaces); + if ((typeof (_g = task.description) !== "undefined" && _g !== null)) { + print(" # " + (task.description)); + } + puts(''); }} if (switches.length) { return puts(oparse.help()); diff --git a/src/cake.coffee b/src/cake.coffee index 53c4d226..2b65507d 100644 --- a/src/cake.coffee +++ b/src/cake.coffee @@ -22,9 +22,10 @@ oparse: null # Mixin the top-level Cake functions for Cakefiles to use directly. helpers.extend global, { - # Define a Cake task with a short name, a sentence description, + # Define a Cake task with a short name, an optional sentence description, # and the function to run as the action itself. task: (name, description, action) -> + [action, description]: [description, action] unless action? tasks[name]: {name: name, description: description, action: action} # Define an option that the Cakefile accepts. The parsed options hash, @@ -59,7 +60,9 @@ print_tasks: -> for name, task of tasks spaces: 20 - name.length spaces: if spaces > 0 then (' ' for i in [0..spaces]).join('') else '' - puts "cake $name$spaces # ${task.description}" + print "cake $name$spaces" + print " # ${task.description}" if task.description? + puts '' puts oparse.help() if switches.length # Print an error and exit when attempting to all an undefined task.