mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
Resolves #593 -- add alias support with local storage
This commit is contained in:
parent
a1f7bda2d9
commit
12cdb49457
3 changed files with 55 additions and 2 deletions
|
@ -3,6 +3,7 @@ var Backbone = require('backbone');
|
|||
var Errors = require('../util/errors');
|
||||
|
||||
var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall;
|
||||
var LevelStore = require('../stores/LevelStore');
|
||||
var intl = require('../intl');
|
||||
|
||||
var CommandProcessError = Errors.CommandProcessError;
|
||||
|
@ -267,8 +268,19 @@ var Command = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
parseAll: function() {
|
||||
var str = this.get('rawStr');
|
||||
var results = this.get('parseWaterfall').parseAll(str);
|
||||
var rawInput = this.get('rawStr');
|
||||
debugger;
|
||||
const aliasMap = LevelStore.getAliasMap();
|
||||
for (var i = 0; i<Object.keys(aliasMap).length; i++) {
|
||||
var alias = Object.keys(aliasMap)[i];
|
||||
var searcher = new RegExp(alias + "(\\s|$)", "g");
|
||||
if (searcher.test(rawInput)) {
|
||||
rawInput = rawInput.replace(searcher, aliasMap[alias] + ' ');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var results = this.get('parseWaterfall').parseAll(rawInput);
|
||||
|
||||
if (!results) {
|
||||
// nothing parsed successfully
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue