Is it possible to pass multiple cmdline args to a Cakefile and capture those values in an array? For example something like this:
option '', '--compilation-level [LEVEL]', 'Description...'
task "build", "compile js", (options)->
compilationLevels = options['compilation-level'] || ['DEFAULT']
if compilationLevels.length >= 2
console.log 'multiple compiles'
else
console.log 'just one compile'
Then run it w/ cake --compilation-level ADVANCED_OPTIMIZATIONS --compilation-level SIMPLE_OPTIMIZATIONS build
If this is not possible then suggestions on the most optimal way to accomplish this would be greatly appreciated 🙂
Yep: Cake is powered by CoffeeScript’s OptionParser, which is ported from the Ruby utility of the same name. If you search the source for
isList, you’ll see that an option can be used multiple times to create an array if (and only if) the regexis fully matched by the long flag name. In short: You just have to add one character to your code.
That
*makes all the difference! 🙂