add a vcs level to the shortcut map

This commit is contained in:
Siddharth Agarwal 2013-07-30 23:50:23 -07:00
parent f14c128174
commit 3c1887f1d0
6 changed files with 34 additions and 38 deletions

View file

@ -25,12 +25,12 @@ var commands = {
},
getShortcutMap: function() {
var map = {};
this.loop(function(config, name) {
var map = {'git': {}};
this.loop(function(config, name, vcs) {
if (!config.sc) {
return;
}
map['git ' + name] = config.sc;
map[vcs][name] = config.sc;
}, this);
return map;
},
@ -73,7 +73,7 @@ var commands = {
},
loop: function(callback, context) {
_.each(commandConfig, callback);
_.each(commandConfig, function (config, name) { callback(config, name, 'git') });
}
};

View file

@ -74,11 +74,13 @@ ParseWaterfall.prototype.expandAllShortcuts = function(commandStr) {
};
ParseWaterfall.prototype.expandShortcut = function(commandStr, shortcutMap) {
_.each(shortcutMap, function(regex, method) {
var results = regex.exec(commandStr);
if (results) {
commandStr = method + ' ' + commandStr.slice(results[0].length);
}
_.each(shortcutMap, function(map, vcs) {
_.each(map, function(regex, method) {
var results = regex.exec(commandStr);
if (results) {
commandStr = vcs + ' ' + method + ' ' + commandStr.slice(results[0].length);
}
});
});
return commandStr;
};