#include <tclap/CmdLine.h>

#include <Configurators/ConsumerConfigurator.h>

ConsumerConfigurator::ConsumerConfigurator(){
	setKafkaIP("127.0.0.1");
	setKafkaPort("9092");
	setTopic("S22_TOPIC_PROCESSED");
	setGroupID("AvroTestGroup");
}


ConsumerConfigurator::ConsumerConfigurator(int argc, char ** argv){
	try {
		TCLAP::CmdLine cmd("Usage Description WIP", ' ', "1");
		cmd.ignoreUnmatched(true);
		TCLAP::ValueArg<std::string> ip("","ip","Kafka Server IP address",false,"127.0.0.1","[127.0.0.1 | 192.168.254.16 ...]");
		cmd.add( ip );
		TCLAP::ValueArg<std::string> port("","port","Kafka IP port",false,"9092","[9092 | 9090 ...]");
		cmd.add( port );
		TCLAP::ValueArg<std::string> topic("","topic","Kafka topic to read from",false,"S22_TOPIC_PROCESSED","[S22_topic | C11_topic |...]");
		cmd.add( topic );
		TCLAP::ValueArg<std::string> groupID("","groupID","The consumer group ID",false,"AvroTestGroup","[AvroTestGroup | ...]");
		cmd.add( groupID );

		cmd.parse( argc, argv );
		setKafkaIP(ip.getValue());
		setKafkaPort(port.getValue());
		setTopic(topic.getValue());
		setGroupID(groupID);

	}catch (TCLAP::ArgException &e){  // catch any exceptions
		std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
		exit(EXIT_FAILURE);
	}
}
