Permalink
Browse files

Storage is now binded to the commands object itself.

  • Loading branch information...
1 parent 0cc4a07 commit c12fb49acfcddca2c775897ba4e43b1d1865da8c @vesln committed Jan 28, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 lib/commands.js
View
@@ -31,6 +31,11 @@ var app = require('./app');
*/
var storage = require('./storage');
+/**
+ * Storage alias.
+ */
+commands.storage = storage;
+
/**
* Prints current version.
*
@@ -47,8 +52,9 @@ commands.version = function() {
* @api public
*/
commands.delete = function(key) {
- storage.del(key, function() {
- storage.save(function(err) {
+ var self = this;
+ this.storage.del(key, function() {
+ self.storage.save(function(err) {
if (err) throw err;
});
});
@@ -61,7 +67,7 @@ commands.delete = function(key) {
* @api public
*/
commands.get = function(key) {
- storage.get(key, function(val) {
+ this.storage.get(key, function(val) {
print(val || 'Nothing found.');
});
};
@@ -73,8 +79,9 @@ commands.get = function(key) {
* @api public
*/
commands.set = function(key, value) {
- storage.set(key, value, function() {
- storage.save(function(err) {
+ var self = this;
+ this.storage.set(key, value, function() {
+ self.storage.save(function(err) {
if (err) throw err;
});
});
@@ -86,7 +93,7 @@ commands.set = function(key, value) {
* @api public
*/
commands.list = function() {
- storage.get(function(data) {
+ this.storage.get(function(data) {
Object.keys(data).forEach(function(key) {
print(key + ': ' + data[key]);
});

0 comments on commit c12fb49

Please sign in to comment.