<spanclass="nv">CoffeeScript = </span><spanclass="nx">require</span><spanclass="s1">'./coffee-script'</span></pre></div></td></tr><trid="section-3"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-3">#</a></div><p>Keep track of the list of defined tasks, the accepted options, and so on.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">tasks = </span><spanclass="p">{}</span>
<spanclass="nv">oparse = </span><spanclass="kc">null</span></pre></div></td></tr><trid="section-4"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-4">#</a></div><p>Mixin the top-level Cake functions for Cakefiles to use directly.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">helpers</span><spanclass="p">.</span><spanclass="nx">extend</span><spanclass="nx">global</span><spanclass="p">,</span></pre></div></td></tr><trid="section-5"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-5">#</a></div><p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">task</span><spanclass="o">:</span><spanclass="p">(</span><spanclass="nx">name</span><spanclass="p">,</span><spanclass="nx">description</span><spanclass="p">,</span><spanclass="nx">action</span><spanclass="p">)</span><spanclass="o">-></span>
<spanclass="nx">tasks</span><spanclass="p">[</span><spanclass="nx">name</span><spanclass="p">]</span><spanclass="o">=</span><spanclass="p">{</span><spanclass="nx">name</span><spanclass="p">,</span><spanclass="nx">description</span><spanclass="p">,</span><spanclass="nx">action</span><spanclass="p">}</span></pre></div></td></tr><trid="section-6"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-6">#</a></div><p>Define an option that the Cakefile accepts. The parsed options hash,
as the first argument to the action.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">option</span><spanclass="o">:</span><spanclass="p">(</span><spanclass="nx">letter</span><spanclass="p">,</span><spanclass="nx">flag</span><spanclass="p">,</span><spanclass="nx">description</span><spanclass="p">)</span><spanclass="o">-></span>
<spanclass="nx">switches</span><spanclass="p">.</span><spanclass="nx">push</span><spanclass="p">[</span><spanclass="nx">letter</span><spanclass="p">,</span><spanclass="nx">flag</span><spanclass="p">,</span><spanclass="nx">description</span><spanclass="p">]</span></pre></div></td></tr><trid="section-7"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-7">#</a></div><p>Invoke another task in the current Cakefile.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">invoke</span><spanclass="o">:</span><spanclass="p">(</span><spanclass="nx">name</span><spanclass="p">)</span><spanclass="o">-></span>
<spanclass="nx">tasks</span><spanclass="p">[</span><spanclass="nx">name</span><spanclass="p">].</span><spanclass="nx">action</span><spanclass="nx">options</span></pre></div></td></tr><trid="section-8"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-8">#</a></div><p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node's
If no tasks are passed, print the help screen.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">exports.run = </span><spanclass="o">-></span>
<spanclass="k">throw</span><spanclass="k">new</span><spanclass="nb">Error</span><spanclass="p">(</span><spanclass="s2">"Cakefile not found in #{process.cwd()}"</span><spanclass="p">)</span><spanclass="nx">unless</span><spanclass="nx">exists</span>
<spanclass="nx">invoke</span><spanclass="nx">arg</span><spanclass="k">for</span><spanclass="nx">arg</span><spanclass="k">in</span><spanclass="nx">options</span><spanclass="p">.</span><spanclass="nx">arguments</span></pre></div></td></tr><trid="section-9"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-9">#</a></div><p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">printTasks = </span><spanclass="o">-></span>
<spanclass="nx">puts</span><spanclass="nx">oparse</span><spanclass="p">.</span><spanclass="nx">help</span><spanclass="p">()</span><spanclass="k">if</span><spanclass="nx">switches</span><spanclass="p">.</span><spanclass="nx">length</span></pre></div></td></tr><trid="section-10"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-10">#</a></div><p>Print an error and exit when attempting to all an undefined task.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nv">missingTask = </span><spanclass="p">(</span><spanclass="nx">task</span><spanclass="p">)</span><spanclass="o">-></span>