@qbyco/tjs-cli
Version:
TrafaletJS CLI Tool
101 lines (88 loc) • 1.42 kB
JavaScript
/**
* @module lib/cli/Command
*/
class Command {
/**
* @class Command
* @constructor
*/
constructor() {
this.name = "help";
this.action = "main";
this.params = [];
this.flags = {};
}
/**
* @method setName
* @param name
* @returns {Command}
*/
setName(name) {
this.name = name;
return this;
}
/**
* @method setAction
* @param action
* @returns {Command}
*/
setAction(action) {
this.action = action;
return this;
}
/**
* @method addParam
* @param {String} param
* @returns {Command}
*/
addParam(param) {
this.params.push(param);
return this;
}
/**
* @method getParams
* @returns {[]|*}
*/
getParams() {
return this.params;
}
/**
* @method addFlag
* @param {String} key
* @param {String|Boolean|Number} value
* @returns {Command}
*/
addFlag(key, value) {
this.flags.setValueOf(key, value);
return this;
}
/**
* @method getFlag
* @param {String} key
*/
getFlag(key) {
return this.flags.getValueOf(key);
}
/**
* @method getFlags
* @returns {{}|*}
*/
getFlags() {
return this.flags;
}
/**
* @method getName
* @returns {string|*}
*/
getName() {
return this.name;
}
/**
* @method getAction
* @returns {null|*}
*/
getAction() {
return this.action;
}
}
module.exports = Command;