The documentation I've seen for Cakefiles seems to be by example, where this serves as a typical example:
option '-v', '--verbose [TRUE|FALSE]', 'Turn verbosity on/off (off by default)'
task 'spec', 'run specs', (options) ->
jasmine = require 'jasmine-node'
# ...
But what happens when I want this:
option '-v', '--verbose [TRUE|FALSE]', 'Turn verbosity on/off (off by default)'
task 'spec', 'run specs', (options) ->
jasmine = require 'jasmine-node'
# ...
option '-d', '--directory [PATH]', 'specific directory to set up the widget in'
task 'createWidgets', 'create the widgets', (options) ->
console.log options.verbose
Options are specific to the file, not the task, which means that (a) options bleed into all tasks in the file, and (b) when running cake
, it's not clear to the user which options are associated with which tasks.
How do I associate options with particular tasks?
There isn't a way to add task-specific options via any of the functions provided by cake.coffee
-- if you look at the source you'll see that options are handled globally. You could write that code yourself, extracting options on a per-task basis by writing code that reads off node's process.argv
. However, cake.coffee
is really quite a bare-bones build tool, and I wouldn't recommend it for anything more than the simplest build systems. You might want to look at something like rake
or make
instead.