actionhero
Version:
The reusable, scalable, and quick node.js API server for stateless and stateful applications
34 lines (33 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLI = void 0;
/**
* An Actionhero CLI Command.
* For inputs, you can provide Options (--thing=stuff) with the "Inputs" object, or define Arguments in the name of the command (`greet [name]`)
*/
class CLI {
constructor() {
var _a, _b, _c, _d, _e;
this.description = (_a = this.description) !== null && _a !== void 0 ? _a : this.name;
this.example = (_b = this.example) !== null && _b !== void 0 ? _b : "";
this.inputs = (_c = this.inputs) !== null && _c !== void 0 ? _c : {};
this.initialize = (_d = this.initialize) !== null && _d !== void 0 ? _d : true;
this.start = (_e = this.start) !== null && _e !== void 0 ? _e : false;
}
/**
* An optional method to append additional information to the --help response for this CLI command
*/
help() { }
validate() {
if (!this.name) {
throw new Error("name is required for this cli command");
}
if (!this.description) {
throw new Error(`description is required for the cli commend \`${this.name}\``);
}
if (!this.run || typeof this.run !== "function") {
throw new Error(`cli command \`${this.name}\` has no run method`);
}
}
}
exports.CLI = CLI;