<commit_before>/*
 * TestRedisLib.cpp
 *
 *  Created on: Feb 21, 2017
 *      Author: bhadoria
 */



#include <stdlib.h>
#include <iostream>

#include "RedisConnection.hpp"
#include "RedisResult.hpp"

using namespace std;

void printResult(const RedisResult& res) {
	switch(res.resultType()) {
	case STRING:
		cout << res.strResult() << endl;
		break;
	case INTEGER:
		cout << res.intResult() << endl;
		break;
	case ARRAY:
		for (int i=0 ; i < res.arraySize() ; i++) {
			printResult((const RedisResult&) res.arrayResult(i));
		}
		break;
	case ERROR:
		cout << res.errMsg() << endl;
		break;
	default:
		cout << NULL << endl;
	}

}

int main(int argc, char **argv) {
	cout << "total args: " << argc << endl;
	for (int i =0; i <argc; i++) {
		cout << i << ": " << argv[i] << endl;
	}
	cout << "connecting to \"" << argv[1] << ":" << argv[2] << "\"" << endl;

	RedisConnection conn(argv[1], atoi(argv[2]));
	if (!conn.isConnected()) {
		cout << "failed to connect." << endl;
		return -1;
	}
	RedisResult res = RedisResult();
	bool done=false;
	while (!done) {
		cout << "CMD> ";
		char message[1024];
		std::cin.getline(message,1023);
		if (conn.cmd(message, res) != 0) {
			done = true;
		} else {
			printResult(res);
		}
	}
    return 0;
}<commit_msg>adding support for subscribing to channel<commit_after>/*
 * TestRedisLib.cpp
 *
 *  Created on: Feb 21, 2017
 *      Author: bhadoria
 */



#include <stdlib.h>
#include <iostream>

#include "RedisConnection.hpp"
#include "RedisResult.hpp"

using namespace std;

void printResult(const RedisResult& res) {
	switch(res.resultType()) {
	case STRING:
		cout << "STRING: " << res.strResult() << endl;
		break;
	case INTEGER:
		cout << "INTEGER: " << res.intResult() << endl;
		break;
	case ARRAY:
		for (int i=0 ; i < res.arraySize() ; i++) {
			printResult((const RedisResult&) res.arrayResult(i));
		}
		break;
	case ERROR:
		cout << "ERROR: " << res.errMsg() << endl;
		break;
	default:
		cout << "<NULL>" << endl;
	}

}

int main(int argc, char **argv) {
	cout << "total args: " << argc << endl;
	for (int i =0; i <argc; i++) {
		cout << i << ": " << argv[i] << endl;
	}
	cout << "connecting to \"" << argv[1] << ":" << argv[2] << "\"" << endl;

	RedisConnection conn(argv[1], atoi(argv[2]));
	if (!conn.isConnected()) {
		cout << "failed to connect." << endl;
		return -1;
	}
	RedisResult res = RedisResult();
	bool done=false;
	bool isSubscribed = false;
	while (!done) {
		char message[1024];
		if (isSubscribed) {
			message[0] = 0;
		} else {
			cout << "CMD> ";
			std::cin.getline(message,1023);
			if (strstr(message, "subscribe") == message || strstr(message, "SUBSCRIBE") == message) {
				isSubscribed = true;
			}
		}
		if (conn.cmd(message, res) != 0 || !conn.isConnected()) {
			done = true;
		} else {
			printResult(res);
		}
	}
    return 0;
}
{'fraction_non_alphanumeric': 0.19495738636363635, 'fraction_numerical': 0.017045454545454544, 'mean_word_length': 3.381026438569207, 'pattern_counts': {'":': 4, '<': 114, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3178762', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1073, 'n_words': 266}