UNPKG

@golemio/cli

Version:

Collection of executables intended for use with Golemio services and modules

58 lines 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const rabbitmq_utils_1 = require("../utils/rabbitmq.utils"); const command = { description: "Send/receive data to RabbitMQ", alias: "rmq", run: async ({ parameters, print }) => { const [action] = parameters.array; const { help, exchange: exchangeName, queueKey, messageOrPathToFile, queueName, dequeue } = parameters.options; if (!process.env.RABBIT_CONN) { print.error("Environmental variable RABBIT_CONN is not defined"); process.exitCode = 1; return; } switch (action) { case "help": case "h": default: (0, rabbitmq_utils_1.printCommandHelp)(); break; case "send": case "s": if (help) { (0, rabbitmq_utils_1.printCommandHelpSend)(); break; } if (!exchangeName) { print.error("Specify exchange. E.g. 'dataplatform'"); process.exitCode = 1; } if (!queueKey) { print.error("Specify queueKey. E.g. 'manual.dataplatform.test.queue'"); process.exitCode = 1; } if (!messageOrPathToFile) { print.error("Specify messageOrPathToFile. E.g. 'Some data' or '/path/to/file.txt'"); process.exitCode = 1; } await (0, rabbitmq_utils_1.sendData)({ exchangeName, queueKey, messageOrPathToFile }); break; case "receive": case "r": if (help) { (0, rabbitmq_utils_1.printCommandHelpReceive)(); break; } if (!queueName) { print.error("Specify queueName. E.g. 'dataplatform.test.queue'"); process.exitCode = 1; } const isDequeue = dequeue && dequeue === "true"; await (0, rabbitmq_utils_1.receiveData)({ queueName, dequeue: isDequeue }); break; } }, }; exports.default = command; //# sourceMappingURL=rabbitmq.js.map