Skip to content

Instantly share code, notes, and snippets.

@drochgenius
Created April 22, 2019 16:02
Show Gist options
  • Save drochgenius/cfd40c68b26dad6c78f5d72e10adb80e to your computer and use it in GitHub Desktop.
Save drochgenius/cfd40c68b26dad6c78f5d72e10adb80e to your computer and use it in GitHub Desktop.
Kafka Producer CLI
#!/usr/bin/env node
/**
* CLI tool to publish messages to Kafka topics
*/
import * as program from 'commander';
import { publish } from './producer';
program
.version('0.0.1')
.usage('[options] <message>')
.option('-t, --topic [topic]', 'Kafka topic', 'test')
.parse(process.argv);
const message: string = program.args.join(' ');
console.log('TOPIC:', program.topic);
console.log('MESSAGE:', message);
publish(program.topic, message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment