new demo command

This commit is contained in:
Peter Cottle 2013-01-12 23:15:13 -08:00
parent 0cb6e43549
commit 22605249ce
3 changed files with 81 additions and 36 deletions

View file

@ -6460,8 +6460,8 @@ var init = function() {
"gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;", "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;",
"git rebase -i HEAD~3; git rebase master; git checkout master; gc;", "git rebase -i HEAD~3; git rebase master; git checkout master; gc;",
"git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;", "git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;",
"show goal; delay 1000; hide goal;", "show goal; delay 1000; hide goal; show solution --force --noReset;",
"git checkout -b win; git commit; help" "help; levels"
].join('')); ].join(''));
}); });
} }
@ -6556,7 +6556,7 @@ var regexMap = {
'start dialog': /^start dialog$/, 'start dialog': /^start dialog$/,
'show goal': /^show goal$/, 'show goal': /^show goal$/,
'hide goal': /^hide goal$/, 'hide goal': /^hide goal$/,
'show solution': /^show solution$/ 'show solution': /^show solution($|\s)/
}; };
var parse = util.genParseCommand(regexMap, 'processLevelCommand'); var parse = util.genParseCommand(regexMap, 'processLevelCommand');
@ -6682,6 +6682,25 @@ var Level = Sandbox.extend({
}, },
showSolution: function(command, deferred) { showSolution: function(command, deferred) {
var toIssue = this.level.solutionCommand;
var issueFunc = function() {
Main.getEventBaton().trigger(
'commandSubmitted',
toIssue
);
};
var commandStr = command.get('rawStr');
if (!this.testOptionOnString(commandStr, 'noReset')) {
toIssue = 'reset; ' + toIssue;
}
if (this.testOptionOnString(commandStr, 'force')) {
issueFunc();
command.finishWith(deferred);
return;
}
// allow them for force the solution
var confirmDefer = Q.defer(); var confirmDefer = Q.defer();
var confirmView = new ConfirmCancelTerminal({ var confirmView = new ConfirmCancelTerminal({
markdowns: [ markdowns: [
@ -6693,15 +6712,7 @@ var Level = Sandbox.extend({
}); });
confirmDefer.promise confirmDefer.promise
.then(_.bind(function() { .then(issueFunc)
// ok great add the solution command
Main.getEventBaton().trigger(
'commandSubmitted',
'reset;' + this.level.solutionCommand
);
this.hideGoal();
command.setResult('Solution command added to the command queue...');
}, this))
.fail(function() { .fail(function() {
command.setResult("Great! I'll let you get back to it"); command.setResult("Great! I'll let you get back to it");
}) })
@ -6836,6 +6847,10 @@ var Level = Sandbox.extend({
return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr')); return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr'));
}, },
testOptionOnString: function(str, option) {
return str && new RegExp('--' + option).test(str);
},
levelSolved: function(defer) { levelSolved: function(defer) {
this.solved = true; this.solved = true;
Main.getEvents().trigger('levelSolved', this.level.id); Main.getEvents().trigger('levelSolved', this.level.id);
@ -18341,8 +18356,8 @@ var init = function() {
"gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;", "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;",
"git rebase -i HEAD~3; git rebase master; git checkout master; gc;", "git rebase -i HEAD~3; git rebase master; git checkout master; gc;",
"git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;", "git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;",
"show goal; delay 1000; hide goal;", "show goal; delay 1000; hide goal; show solution --force --noReset;",
"git checkout -b win; git commit; help" "help; levels"
].join('')); ].join(''));
}); });
} }
@ -21259,7 +21274,7 @@ var regexMap = {
'start dialog': /^start dialog$/, 'start dialog': /^start dialog$/,
'show goal': /^show goal$/, 'show goal': /^show goal$/,
'hide goal': /^hide goal$/, 'hide goal': /^hide goal$/,
'show solution': /^show solution$/ 'show solution': /^show solution($|\s)/
}; };
var parse = util.genParseCommand(regexMap, 'processLevelCommand'); var parse = util.genParseCommand(regexMap, 'processLevelCommand');
@ -21385,6 +21400,25 @@ var Level = Sandbox.extend({
}, },
showSolution: function(command, deferred) { showSolution: function(command, deferred) {
var toIssue = this.level.solutionCommand;
var issueFunc = function() {
Main.getEventBaton().trigger(
'commandSubmitted',
toIssue
);
};
var commandStr = command.get('rawStr');
if (!this.testOptionOnString(commandStr, 'noReset')) {
toIssue = 'reset; ' + toIssue;
}
if (this.testOptionOnString(commandStr, 'force')) {
issueFunc();
command.finishWith(deferred);
return;
}
// allow them for force the solution
var confirmDefer = Q.defer(); var confirmDefer = Q.defer();
var confirmView = new ConfirmCancelTerminal({ var confirmView = new ConfirmCancelTerminal({
markdowns: [ markdowns: [
@ -21396,15 +21430,7 @@ var Level = Sandbox.extend({
}); });
confirmDefer.promise confirmDefer.promise
.then(_.bind(function() { .then(issueFunc)
// ok great add the solution command
Main.getEventBaton().trigger(
'commandSubmitted',
'reset;' + this.level.solutionCommand
);
this.hideGoal();
command.setResult('Solution command added to the command queue...');
}, this))
.fail(function() { .fail(function() {
command.setResult("Great! I'll let you get back to it"); command.setResult("Great! I'll let you get back to it");
}) })
@ -21539,6 +21565,10 @@ var Level = Sandbox.extend({
return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr')); return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr'));
}, },
testOptionOnString: function(str, option) {
return str && new RegExp('--' + option).test(str);
},
levelSolved: function(defer) { levelSolved: function(defer) {
this.solved = true; this.solved = true;
Main.getEvents().trigger('levelSolved', this.level.id); Main.getEvents().trigger('levelSolved', this.level.id);

View file

@ -125,8 +125,8 @@ var init = function() {
"gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;", "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc;",
"git rebase -i HEAD~3; git rebase master; git checkout master; gc;", "git rebase -i HEAD~3; git rebase master; git checkout master; gc;",
"git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;", "git merge bugFix; levels --noOutput; level rebase1 --noFinishDialog --noStartCommand;",
"show goal; delay 1000; hide goal;", "show goal; delay 1000; hide goal; show solution --force --noReset;",
"git checkout -b win; git commit; help" "help; levels"
].join('')); ].join(''));
}); });
} }

View file

@ -27,7 +27,7 @@ var regexMap = {
'start dialog': /^start dialog$/, 'start dialog': /^start dialog$/,
'show goal': /^show goal$/, 'show goal': /^show goal$/,
'hide goal': /^hide goal$/, 'hide goal': /^hide goal$/,
'show solution': /^show solution$/ 'show solution': /^show solution($|\s)/
}; };
var parse = util.genParseCommand(regexMap, 'processLevelCommand'); var parse = util.genParseCommand(regexMap, 'processLevelCommand');
@ -153,6 +153,25 @@ var Level = Sandbox.extend({
}, },
showSolution: function(command, deferred) { showSolution: function(command, deferred) {
var toIssue = this.level.solutionCommand;
var issueFunc = function() {
Main.getEventBaton().trigger(
'commandSubmitted',
toIssue
);
};
var commandStr = command.get('rawStr');
if (!this.testOptionOnString(commandStr, 'noReset')) {
toIssue = 'reset; ' + toIssue;
}
if (this.testOptionOnString(commandStr, 'force')) {
issueFunc();
command.finishWith(deferred);
return;
}
// allow them for force the solution
var confirmDefer = Q.defer(); var confirmDefer = Q.defer();
var confirmView = new ConfirmCancelTerminal({ var confirmView = new ConfirmCancelTerminal({
markdowns: [ markdowns: [
@ -164,15 +183,7 @@ var Level = Sandbox.extend({
}); });
confirmDefer.promise confirmDefer.promise
.then(_.bind(function() { .then(issueFunc)
// ok great add the solution command
Main.getEventBaton().trigger(
'commandSubmitted',
'reset;' + this.level.solutionCommand
);
this.hideGoal();
command.setResult('Solution command added to the command queue...');
}, this))
.fail(function() { .fail(function() {
command.setResult("Great! I'll let you get back to it"); command.setResult("Great! I'll let you get back to it");
}) })
@ -307,6 +318,10 @@ var Level = Sandbox.extend({
return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr')); return this.options.command && new RegExp('--' + option).test(this.options.command.get('rawStr'));
}, },
testOptionOnString: function(str, option) {
return str && new RegExp('--' + option).test(str);
},
levelSolved: function(defer) { levelSolved: function(defer) {
this.solved = true; this.solved = true;
Main.getEvents().trigger('levelSolved', this.level.id); Main.getEvents().trigger('levelSolved', this.level.id);