actionhero
Version:
The reusable, scalable, and quick node.js API server for stateless and stateful applications
38 lines (37 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskEnqueueCLI = void 0;
const index_1 = require("./../../../index");
class TaskEnqueueCLI extends index_1.CLI {
constructor() {
super(...arguments);
this.name = "task-enqueue";
this.description = "Enqueue a defined Task into your actionhero cluster";
this.example = "actionhero task enqueue --name=[taskName] --args=[JSON-encoded args]";
this.inputs = {
name: {
required: true,
description: "The name of the Task to enqueue",
letter: "n",
},
args: {
required: false,
description: "Arguments to the Task (JSON encoded)",
letter: "a",
},
};
}
async run({ params }) {
if (!index_1.api.tasks.tasks[params.name]) {
throw new Error('Task "' + params.name + '" not found');
}
let args = {};
if (params.args) {
args = JSON.parse(params.args);
}
const toRun = await index_1.task.enqueue(params.name, args);
(0, index_1.log)(`enqueued: ${toRun}`, "info");
return true;
}
}
exports.TaskEnqueueCLI = TaskEnqueueCLI;