Skip to content

Commit

Permalink
Implemented command order for the CLI binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
André König committed Mar 21, 2013
1 parent 4bbb2c4 commit e69f7df
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/add.js
Expand Up @@ -19,6 +19,11 @@ module.exports = function (configuration) {
var addCmd = {};

Object.defineProperties(addCmd, {
"id": {
enumerable: true,
writable: false,
value: 2
},
"pattern": {
enumerable: true,
writable: false,
Expand Down
5 changes: 5 additions & 0 deletions lib/all.js
Expand Up @@ -19,6 +19,11 @@ module.exports = function (configuration, datastore) {
var allCmd = {};

Object.defineProperties(allCmd, {
"id": {
enumerable: true,
writable: false,
value: 3
},
"pattern": {
enumerable: true,
writable: false,
Expand Down
5 changes: 5 additions & 0 deletions lib/archive.js
Expand Up @@ -19,6 +19,11 @@ module.exports = function (configuration, datastore) {
var archiveCmd = {};

Object.defineProperties(archiveCmd, {
"id": {
enumerable: true,
writable: false,
value: 4
},
"pattern": {
enumerable: true,
writable: false,
Expand Down
5 changes: 5 additions & 0 deletions lib/init.js
Expand Up @@ -19,6 +19,11 @@ module.exports = function (configuration) {
var initCmd = {};

Object.defineProperties(initCmd, {
"id": {
enumerable: true,
writable: false,
value: 1
},
"pattern": {
enumerable: true,
writable: false,
Expand Down
20 changes: 16 additions & 4 deletions lib/jutebag.js
Expand Up @@ -8,10 +8,11 @@
*
*/

var fs = require("fs"),
path = require("path"),
storage = require("./utils/storage"),
HOME = process.env[(process.platform === "win32") ? "USERPROFILE" : "HOME"] + path.sep + ".jutebag";
var fs = require("fs"),
path = require("path"),
storage = require("./utils/storage"),
underscore = require("underscore"),
HOME = process.env[(process.platform === "win32") ? "USERPROFILE" : "HOME"] + path.sep + ".jutebag";

;(function () {
"use strict";
Expand Down Expand Up @@ -46,4 +47,15 @@ var fs = require("fs"),
jutebag.commands[module] = require('./' + module)(jutebag.configuration, jutebag.datastore);
}
});

// Sort the commands
if (underscore.isObject(jutebag.commands)) {
jutebag.commands = underscore.toArray(jutebag.commands);
}

jutebag.commands = jutebag.commands.sort(function (cmd1, cmd2) {
return cmd1.id - cmd2.id;
});

console.log(jutebag.commands);
})();
5 changes: 5 additions & 0 deletions lib/unread.js
Expand Up @@ -19,6 +19,11 @@ module.exports = function (configuration, datastore) {
var unreadCmd = {};

Object.defineProperties(unreadCmd, {
"id": {
enumerable: true,
writable: false,
value: 5
},
"pattern": {
enumerable: true,
writable: false,
Expand Down

0 comments on commit e69f7df

Please sign in to comment.