Swap-Aggregator-Subgraph/node_modules/gluegun/build/domain/command.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

57 lines
1.7 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* A command is user-callable function that runs stuff.
*/
var Command = /** @class */ (function () {
function Command(props) {
this.name = null;
this.description = null;
this.file = null;
this.run = null;
this.hidden = false;
this.commandPath = null;
this.alias = [];
this.dashed = false;
this.plugin = null;
if (props)
Object.assign(this, props);
}
Object.defineProperty(Command.prototype, "aliases", {
/**
* Returns normalized list of aliases.
*
* @returns list of aliases.
*/
get: function () {
if (!this.alias)
return [];
return Array.isArray(this.alias) ? this.alias : [this.alias];
},
enumerable: true,
configurable: true
});
/**
* Checks if the command has any aliases at all.
*
* @returns whether the command has any aliases
*/
Command.prototype.hasAlias = function () {
return this.aliases.length > 0;
};
/**
* Checks if a given alias matches with this command's aliases, including name.
* Can take a list of aliases too and check them all.
*
* @param alias
* @returns whether the alias[es] matches
*/
Command.prototype.matchesAlias = function (alias) {
var _this = this;
var aliases = Array.isArray(alias) ? alias : [alias];
return Boolean(aliases.find(function (a) { return _this.name === a || _this.aliases.includes(a); }));
};
return Command;
}());
exports.Command = Command;
//# sourceMappingURL=command.js.map