61 lines
5.9 KiB
JavaScript
61 lines
5.9 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
var plugins = require("./smartcli.plugins");
|
|
var Smartcli = (function () {
|
|
function Smartcli() {
|
|
this.argv = plugins.argv;
|
|
this.questionsDone = plugins.q.defer();
|
|
this.parseStarted = plugins.q.defer();
|
|
}
|
|
Smartcli.prototype.addAlias = function (keyArg, aliasArg) {
|
|
this.argv = this.argv.alias(keyArg, aliasArg);
|
|
};
|
|
;
|
|
Smartcli.prototype.addCommand = function (definitionArg) {
|
|
var _this = this;
|
|
var done = plugins.q.defer();
|
|
this.parseStarted
|
|
.then(function () {
|
|
if (_this.argv._.indexOf(definitionArg.commandName) == 0) {
|
|
done.resolve();
|
|
}
|
|
else {
|
|
return done.reject();
|
|
}
|
|
});
|
|
return done.promsise;
|
|
};
|
|
;
|
|
Smartcli.prototype.addQuestion = function (definitionArg) {
|
|
};
|
|
;
|
|
Smartcli.prototype.addVersion = function (versionArg) {
|
|
this.version = versionArg;
|
|
this.parseStarted
|
|
.then(function () {
|
|
});
|
|
};
|
|
Smartcli.prototype.standardTask = function () {
|
|
var _this = this;
|
|
var done = plugins.q.defer();
|
|
this.parseStarted
|
|
.then(function () {
|
|
if (plugins.argv._.length == 0 || _this.commands.length == 0) {
|
|
done.resolve();
|
|
}
|
|
else {
|
|
done.reject();
|
|
}
|
|
;
|
|
});
|
|
return done.promise;
|
|
};
|
|
Smartcli.prototype.startParse = function () {
|
|
this.parseStarted.resolve();
|
|
};
|
|
return Smartcli;
|
|
}());
|
|
exports.Smartcli = Smartcli;
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUV4QixJQUFZLE9BQU8sV0FBTSxvQkFDekI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iAgICAgICAgcmV0dXJuIGRvbmUucHJvbXNpc2U7XG4gICAgfTtcbiAgICBhZGRRdWVzdGlvbihkZWZpbml0aW9uQXJnOntxdWVzdGlvblN0cmluZzpzdHJpbmcscXVlc3Rpb25UeXBlOnN0cmluZ30pe1xuICAgICAgICBcbiAgICB9O1xuICAgIGFkZFZlcnNpb24odmVyc2lvbkFyZzpzdHJpbmcpe1xuICAgICAgICB0aGlzLnZlcnNpb24gPSB2ZXJzaW9uQXJnO1xuICAgICAgICB0aGlzLnBhcnNlU3RhcnRlZFxuICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuXG4gICAgICAgICAgICB9KVxuICAgIH1cbiAgICBzdGFuZGFyZFRhc2soKXtcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcbiAgICAgICAgdGhpcy5wYXJzZVN0YXJ0ZWRcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICBpZihwbHVnaW5zLmFyZ3YuXy5sZW5ndGggPT0gMCB8fCB0aGlzLmNvbW1hbmRzLmxlbmd0aCA9PSAwKXtcbiAgICAgICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZG9uZS5yZWplY3QoKTtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIHN0YXJ0UGFyc2UoKXtcbiAgICAgICAgdGhpcy5wYXJzZVN0YXJ0ZWQucmVzb2x2ZSgpO1xuICAgIH1cblxufSJdfQ==
|