add a vcs level to the option map

This commit is contained in:
Siddharth Agarwal 2013-07-31 00:06:07 -07:00
parent b71e794e8e
commit d3f933ff2d

View file

@ -36,15 +36,15 @@ var commands = {
}, },
getOptionMap: function() { getOptionMap: function() {
var optionMap = {}; var optionMap = {'git': {}};
this.loop(function(config, name) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
var thisMap = {}; var thisMap = {};
// start all options off as disabled // start all options off as disabled
_.each(config.options, function(option) { _.each(config.options, function(option) {
thisMap[option] = false; thisMap[option] = false;
}); });
optionMap[displayName] = thisMap; optionMap[vcs][displayName] = thisMap;
}); });
return optionMap; return optionMap;
}, },
@ -536,7 +536,7 @@ var instantCommands = [
intl.str('git-supported-commands'), intl.str('git-supported-commands'),
'<br/>' '<br/>'
]; ];
var commands = commands.getOptionMap(); var commands = commands.getOptionMap()['git'];
// build up a nice display of what we support // build up a nice display of what we support
_.each(commands, function(commandOptions, command) { _.each(commands, function(commandOptions, command) {
lines.push('git ' + command); lines.push('git ' + command);
@ -574,7 +574,7 @@ var parse = function(str) {
// we support this command! // we support this command!
// parse off the options and assemble the map / general args // parse off the options and assemble the map / general args
var parsedOptions = new CommandOptionParser(method, options); var parsedOptions = new CommandOptionParser(vcs, method, options);
return { return {
toSet: { toSet: {
generalArgs: parsedOptions.generalArgs, generalArgs: parsedOptions.generalArgs,
@ -590,11 +590,12 @@ var parse = function(str) {
/** /**
* CommandOptionParser * CommandOptionParser
*/ */
function CommandOptionParser(method, options) { function CommandOptionParser(vcs, method, options) {
this.vcs = vcs;
this.method = method; this.method = method;
this.rawOptions = options; this.rawOptions = options;
this.supportedMap = commands.getOptionMap()[method]; this.supportedMap = commands.getOptionMap()[vcs][method];
if (this.supportedMap === undefined) { if (this.supportedMap === undefined) {
throw new Error('No option map for ' + method); throw new Error('No option map for ' + method);
} }