Permalink
Browse files

[api docs] Added more commands. Updated docs

  • Loading branch information...
1 parent f94720d commit f2d51cf69b86d7492acaf24de58dbb6897c7dfd8 @indexzero indexzero committed Mar 5, 2011
View
@@ -3,19 +3,11 @@
require.paths.unshift(require('path').join(__dirname, '..', 'lib'));
var eyes = require('eyes'),
+ colors = require('colors'),
+ winston = require('winston'),
argv = require('optimist').argv,
jitsu = require('jitsu');
-var resources = [
- 'apps',
- 'snapshots'
-];
-
-var operations = [
- 'password',
-
-];
-
jitsu.start(argv._.join(' '), function () {
-
+ winston.info('Nodejitsu'.grey + ' ok'.yellow.bold);
});
View
@@ -123,7 +123,7 @@ table td {
}
pre, tt, code {
font-size: 12px; line-height: 18px;
- font-family: Monaco, Consolas, "Lucida Console", monospace;
+ font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
View
@@ -43,6 +43,8 @@ <h4>@callback {function} Continuation to pass control to when complete.</h4>
<p>Starts the jitsu CLI and runs the specified command.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">jitsu</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Setup the initial prompt but don't leave it open</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">prompt</span><span class="p">.</span><span class="nx">start</span><span class="p">().</span><span class="nx">pause</span><span class="p">();</span>
<span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Welcome to &#39;</span> <span class="o">+</span> <span class="s1">&#39;Nodejitsu&#39;</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;It worked if it ends with &#39;</span> <span class="o">+</span> <span class="s1">&#39;Nodejitsu&#39;</span><span class="p">.</span><span class="nx">grey</span> <span class="o">+</span> <span class="s1">&#39; ok&#39;</span><span class="p">.</span><span class="nx">yellow</span><span class="p">.</span><span class="nx">bold</span><span class="p">);</span>
+
<span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">username</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">setupUser</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
@@ -73,7 +75,8 @@ <h4>@callback {function} Continuation to pass control to when complete.</h4>
<span class="nx">winston</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
<span class="k">return</span>
<span class="p">}</span>
- </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>TODO (indexzero): Something here</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">});</span>
+ </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>TODO (indexzero): Something here</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h3>function setup (callback)</h3>
<h4>@callback {function} Continuation to pass control to when complete.</h4>
View
@@ -35,7 +35,7 @@ <h4>@callback {function} Continuation to pass control to when complete.</h4>
check the arguments length then execute the command.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">parts</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">callback</span><span class="p">);</span>
<span class="nx">expected</span> <span class="o">=</span> <span class="nx">resource</span><span class="p">[</span><span class="nx">action</span><span class="p">].</span><span class="nx">length</span><span class="p">;</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">parts</span><span class="p">.</span><span class="nx">length</span> <span class="o">!==</span> <span class="nx">expected</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">parts</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="nx">expected</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Wrong number of arguments: &#39;</span> <span class="o">+</span> <span class="nx">parts</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s1">&#39; for &#39;</span> <span class="o">+</span> <span class="nx">expected</span><span class="p">))</span>
<span class="p">}</span>
@@ -5,7 +5,8 @@
<span class="cm"> *</span>
<span class="cm"> */</span>
-<span class="kd">var</span> <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;jitsu&#39;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">apps</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
@@ -24,7 +25,7 @@
<span class="p">]);</span>
<span class="p">});</span>
- <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">stringifyRows</span><span class="p">(</span><span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">));</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">logRows</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">};</span>
@@ -10,20 +10,33 @@
<span class="kd">var</span> <span class="nx">snapshots</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
<span class="nx">snapshots</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">jitsu</span><span class="p">.</span><span class="nx">snapshots</span><span class="p">.</span><span class="nx">list</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">snapshots</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">rows</span> <span class="o">=</span> <span class="p">[[</span><span class="s1">&#39;filename&#39;</span><span class="p">,</span> <span class="s1">&#39;created&#39;</span><span class="p">,</span> <span class="s1">&#39;md5&#39;</span><span class="p">]],</span>
- <span class="nx">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;underline&#39;</span><span class="p">,</span> <span class="s1">&#39;yellow&#39;</span><span class="p">,</span> <span class="s1">&#39;grey&#39;</span><span class="p">];</span>
-
- <span class="nx">snapshots</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">snap</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">rows</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span>
- <span class="nx">snap</span><span class="p">.</span><span class="nx">filename</span><span class="p">,</span>
- <span class="nx">jitsu</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">snapshotTime</span><span class="p">(</span><span class="nx">snap</span><span class="p">.</span><span class="nx">filename</span><span class="p">),</span>
- <span class="nx">snap</span><span class="p">.</span><span class="nx">md5</span>
- <span class="p">]);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
+ <span class="k">return</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">readPackage</span><span class="p">(</span><span class="nx">process</span><span class="p">.</span><span class="nx">cwd</span><span class="p">(),</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="kr">package</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">name</span> <span class="o">=</span> <span class="kr">package</span><span class="p">.</span><span class="nx">name</span><span class="p">;</span>
+ <span class="nx">executeList</span><span class="p">();</span>
<span class="p">});</span>
-
- <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">jitsu</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">stringifyRows</span><span class="p">(</span><span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">));</span>
- <span class="p">});</span>
+ <span class="p">}</span>
+
+ <span class="kd">function</span> <span class="nx">executeList</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">snapshots</span><span class="p">.</span><span class="nx">list</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">snapshots</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">rows</span> <span class="o">=</span> <span class="p">[[</span><span class="s1">&#39;filename&#39;</span><span class="p">,</span> <span class="s1">&#39;created&#39;</span><span class="p">,</span> <span class="s1">&#39;md5&#39;</span><span class="p">]],</span>
+ <span class="nx">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;underline&#39;</span><span class="p">,</span> <span class="s1">&#39;yellow&#39;</span><span class="p">,</span> <span class="s1">&#39;grey&#39;</span><span class="p">];</span>
+
+ <span class="nx">snapshots</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">snap</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">rows</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span>
+ <span class="nx">snap</span><span class="p">.</span><span class="nx">filename</span><span class="p">,</span>
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">snapshotTime</span><span class="p">(</span><span class="nx">snap</span><span class="p">.</span><span class="nx">filename</span><span class="p">),</span>
+ <span class="nx">snap</span><span class="p">.</span><span class="nx">md5</span>
+ <span class="p">]);</span>
+ <span class="p">});</span>
+
+ <span class="nx">jitsu</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">logRows</span><span class="p">(</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">);</span>
+ <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+
+ <span class="nx">executeList</span><span class="p">();</span>
<span class="p">};</span>
<span class="nx">snapshots</span><span class="p">.</span><span class="nx">create</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
View
@@ -22,16 +22,18 @@
<span class="nx">verbose</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nx">prompt</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nx">info</span><span class="o">:</span> <span class="mi">4</span><span class="p">,</span>
- <span class="nx">warn</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span>
- <span class="nx">debug</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span>
- <span class="nx">error</span><span class="o">:</span> <span class="mi">7</span>
+ <span class="nx">data</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span>
+ <span class="nx">warn</span><span class="o">:</span> <span class="mi">6</span><span class="p">,</span>
+ <span class="nx">debug</span><span class="o">:</span> <span class="mi">7</span><span class="p">,</span>
+ <span class="nx">error</span><span class="o">:</span> <span class="mi">8</span>
<span class="p">},</span>
<span class="nx">colors</span><span class="o">:</span> <span class="p">{</span>
<span class="nx">silly</span><span class="o">:</span> <span class="s1">&#39;magenta&#39;</span><span class="p">,</span>
<span class="nx">input</span><span class="o">:</span> <span class="s1">&#39;grey&#39;</span><span class="p">,</span>
<span class="nx">verbose</span><span class="o">:</span> <span class="s1">&#39;cyan&#39;</span><span class="p">,</span>
<span class="nx">prompt</span><span class="o">:</span> <span class="s1">&#39;grey&#39;</span><span class="p">,</span>
<span class="nx">info</span><span class="o">:</span> <span class="s1">&#39;green&#39;</span><span class="p">,</span>
+ <span class="nx">data</span><span class="o">:</span> <span class="s1">&#39;cyan&#39;</span><span class="p">,</span>
<span class="nx">warn</span><span class="o">:</span> <span class="s1">&#39;yellow&#39;</span><span class="p">,</span>
<span class="nx">debug</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span><span class="p">,</span>
<span class="nx">error</span><span class="o">:</span> <span class="s1">&#39;red&#39;</span>
View
@@ -82,6 +82,12 @@ <h4>@colors {Array} Set of colors to use for the headers</h4>
<span class="p">});</span>
<span class="k">return</span> <span class="nx">output</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">);</span>
+<span class="p">};</span>
+
+<span class="nx">log</span><span class="p">.</span><span class="nx">logRows</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">level</span><span class="p">,</span> <span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">log</span><span class="p">.</span><span class="nx">stringifyRows</span><span class="p">(</span><span class="nx">rows</span><span class="p">,</span> <span class="nx">colors</span><span class="p">).</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">str</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">winston</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">level</span><span class="p">,</span> <span class="nx">str</span><span class="p">);</span>
+ <span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>function putObjects (objs, properties, colors)</h3>
<h4>@objs {Array} List of objects to create output for</h4>
Oops, something went wrong.

0 comments on commit f2d51cf

Please sign in to comment.