<commit_before>#include <iostream>
#include <boost/lexical_cast.hpp>
#include "wc/Mediator.hpp"
#include "wc/WordCountIO.hpp"
#include "wc/OptionParser.hpp"

int main(int argc, char** argv)
{
//	if (argc < 3) {
//		std::cout << "ERROR" << std::endl;
//		return 1;
//	}
//
//	Options options;
//	options.path = argv[1];
//	options.firstN = boost::lexical_cast<std::size_t>(argv[2]);

	namespace po = boost::program_options;

	po::options_description general("General options");
	general.add_options()
		("debug,d", "turn on debug")
		("help,h", /*po::bool_switch(&dohelp),*/ "produce help message");

	wc::OptionParser optionsParser(argc, argv);
	optionsParser.parse();

	po::options_description all("Allowed options");
	all.add(general).add(optionsParser.getOptionsDescription());

	po::variables_map vm;
	store(parse_command_line(argc, argv, all), vm);
	po::notify(vm);

	if (vm.count("help")) {
	    std::cout << all << "\n";
	    return 0;
	}

	wc::Mediator m(optionsParser.getOptions()); m();
	std::cout << m.getWordCount() << std::flush;

	return 0;
}<commit_msg>initial exception handlin in bin<commit_after>#include <iostream>
#include <boost/lexical_cast.hpp>
#include <boost/exception/all.hpp>
#include "wc/Mediator.hpp"
#include "wc/WordCountIO.hpp"
#include "wc/OptionParser.hpp"

int main(int argc, char** argv)
{
	namespace po = boost::program_options;

	try {
		po::options_description general("General options");
		general.add_options()
			("debug,d", "turn on debug")
			("help,h", /*po::bool_switch(&dohelp),*/ "produce help message");

		wc::OptionParser optionsParser(argc, argv);
		optionsParser.parse();

		po::options_description all("Allowed options");
		all.add(general).add(optionsParser.getOptionsDescription());

		po::variables_map vm;
		store(parse_command_line(argc, argv, all), vm);
		po::notify(vm);

		if (vm.count("help")) {
			std::cout << all << "\n";
			return 0;
		}

		wc::Mediator m(optionsParser.getOptions()); m();
		std::cout << m.getWordCount() << std::flush;
	} catch (std::exception& e) {
		std::cerr << boost::diagnostic_information(e) << std::endl;
		return 1;
	}

	return 0;
}
{'fraction_non_alphanumeric': 0.18964705882352942, 'fraction_numerical': 0.0042352941176470585, 'mean_word_length': 5.198250728862973, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 9, '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': '169174', 'n_tokens_mistral': 789, 'n_tokens_neox': 741, 'n_words': 151}