YAYYYyyy giatn refactor

This commit is contained in:
Peter Cottle 2012-12-27 14:48:04 -08:00
parent 171e4c8351
commit d497bea70c
7 changed files with 654 additions and 451 deletions

View file

@ -9,7 +9,7 @@ var GitError = Errors.GitError;
var Warning = Errors.Warning;
var CommandResult = Errors.CommandResult;
var sandboxInstantCommands = [
var instantCommands = [
[/^ls/, function() {
throw new CommandResult({
msg: "DontWorryAboutFilesInThisDemo.txt"
@ -20,45 +20,6 @@ var sandboxInstantCommands = [
msg: "Directory Changed to '/directories/dont/matter/in/this/demo'"
});
}],
[/^git help($|\s)/, function() {
// sym link this to the blank git command
var allCommands = Command.prototype.getSandboxCommands();
// wow this is hacky :(
var equivalent = 'git';
_.each(allCommands, function(bits) {
var regex = bits[0];
if (regex.test(equivalent)) {
bits[1]();
}
});
}],
[/^git$/, function() {
var lines = [
'Git Version PCOTTLE.1.0',
'<br/>',
'Usage:',
_.escape('\t git <command> [<args>]'),
'<br/>',
'Supported commands:',
'<br/>'
];
var commands = GitOptionParser.prototype.getMasterOptionMap();
// build up a nice display of what we support
_.each(commands, function(commandOptions, command) {
lines.push('git ' + command);
_.each(commandOptions, function(vals, optionName) {
lines.push('\t ' + optionName);
}, this);
}, this);
// format and throw
var msg = lines.join('\n');
msg = msg.replace(/\t/g, '&nbsp;&nbsp;&nbsp;');
throw new CommandResult({
msg: msg
});
}],
[/^refresh$/, function() {
var events = require('../app').getEvents();
@ -78,4 +39,4 @@ var sandboxInstantCommands = [
}]
];
exports.sandboxInstantCommands = sandboxInstantCommands;
exports.instantCommands = instantCommands;