Skip to content
Browse files

Swaping app and cli.

  • Loading branch information...
1 parent 7c8fce1 commit aa1c31405fc7a679fc05d3ee5c9d812cb7fa225c @vesln committed Jan 29, 2012
Showing with 49 additions and 31 deletions.
  1. +3 −27 lib/app.js
  2. +22 −4 lib/cli.js
  3. +24 −0 test/app.test.js
View
30 lib/app.js
@@ -7,8 +7,9 @@
/**
* Module dependencies.
- */
+ */
var flatiron = require('flatiron');
+var path = require('path');
/**
* The application object.
@@ -17,36 +18,11 @@ var flatiron = require('flatiron');
*/
var app = module.exports = flatiron.app;
-/**
- * Commands.
- *
- * @type {Object}
- */
-var commands = require('./commands');
-
app.use(flatiron.plugins.cli, {
usage: [
'',
'todo',
'',
'Author: Veselin Todorov <hi@vesln.com>'
]
-});
-
-// Version.
-app.cmd(/version/, commands.version);
-
-// Lists all todo items.
-app.cmd(/ls/, commands.list);
-
-// Marks a todo item as done.
-app.cmd(/check (.+)/, commands.check);
-
-// Marks a todo item as not done yet.
-app.cmd(/undo (.+)/, commands.undo);
-
-// Removes a todo item.
-app.cmd(/rm (.+)/, commands.delete);
-
-// Adds new todo item.
-app.cmd(/(.+)/, commands.add);
+});
View
26 lib/cli.js
@@ -7,19 +7,37 @@
/**
* Module dependencies.
- */
-var path = require('path');
+ */
+var flatiron = require('flatiron');
/**
* The application object.
*
* @type {Object}
*/
-var app = module.exports = require('./app');
+var app = module.exports = require('./app')
/**
* Commands.
*
* @type {Object}
*/
-var commands = require('./commands');
+var commands = require('./commands');
+
+// Version.
+app.cmd(/version/, commands.version);
+
+// Lists all todo items.
+app.cmd(/ls/, commands.list);
+
+// Marks a todo item as done.
+app.cmd(/check (.+)/, commands.check);
+
+// Marks a todo item as not done yet.
+app.cmd(/undo (.+)/, commands.undo);
+
+// Removes a todo item.
+app.cmd(/rm (.+)/, commands.delete);
+
+// Adds new todo item.
+app.cmd(/(.+)/, commands.add);
View
24 test/app.test.js
@@ -0,0 +1,24 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
+/**
+ * Test dependencies.
+ */
+var flatiron = require('flatiron');
+
+/**
+ * The tests object.
+ *
+ * @type {Object}
+ */
+var app = require('../lib/app');
+
+describe('app', function() {
+ it('should be flatiron app', function() {
+ app.should.eql(flatiron.app);
+ });
+});

0 comments on commit aa1c314

Please sign in to comment.
Something went wrong with that request. Please try again.