<commit_before>#include <cstdlib>
#include <iostream>
#include "natstat.hpp"
#include "natstat_util.hpp"
#include "string_util.hpp"
#include <stdexcept>

void show_help()
{
	std::cerr<<"  Usage:  ./natstat [--help][h][--wof][-w]"<<std::endl;
	std::cerr<<"  --help, -h  Show help menu."<<std::endl;
	std::cerr<<"  --wof, -w   Print in wof format."<<std::endl;
}

int main(int argc,char* argv[])
{
	try
	{
		std::cerr<<"Not Another Netstat"<<std::endl;
		bool human_readable=true;
		for(int ii=1;ii<argc;++ii)
		{
			std::string cli(argv[ii]);
			if(cli=="--help"||cli=="-h")
			{
				show_help();
				return 1;
			}
			else if(cli=="--wof"||cli=="-w")
			{
				human_readable=false;
			}
			else
			{
				throw std::runtime_error("Unknown cli argument \""+cli+"\".");
			}
		}
		natstat_list_t natstats(natstat());
		if(human_readable)
			print_human(natstats);
		else
			print_wof(natstats);
	}
	catch(std::runtime_error& error)
	{
		std::cerr<<"Error - "<<error.what()<<std::endl;
		show_help();
		exit(1);
	}
	catch(...)
	{
		std::cerr<<"Unknown error occured."<<std::endl;
		show_help();
		exit(1);
	}
	return 0;
}
<commit_msg>Refactor.<commit_after>#include <cstdlib>
#include <iostream>
#include "natstat.hpp"
#include "natstat_util.hpp"
#include "string_util.hpp"
#include <stdexcept>

void show_help()
{
	std::cerr<<"  Usage:  ./natstat [--help][h][--wof][-w]"<<std::endl;
	std::cerr<<"  --help, -h  Show help menu."<<std::endl;
	std::cerr<<"  --wof, -w   Print in wof format."<<std::endl;
}

int main(int argc,char* argv[])
{
	try
	{
		std::cerr<<"Not Another Netstat"<<std::endl;
		bool human_readable=true;
		for(int ii=1;ii<argc;++ii)
		{
			std::string cli(argv[ii]);
			if(cli=="--help"||cli=="-h")
			{
				show_help();
				return 1;
			}
			if(cli=="--wof"||cli=="-w")
				human_readable=false;
			else
				throw std::runtime_error("Unknown cli argument \""+cli+"\".");
		}
		natstat_list_t natstats(natstat());
		if(human_readable)
			print_human(natstats);
		else
			print_wof(natstats);
	}
	catch(std::runtime_error& error)
	{
		std::cerr<<"Error - "<<error.what()<<std::endl;
		show_help();
		exit(1);
	}
	catch(...)
	{
		std::cerr<<"Unknown error occured."<<std::endl;
		show_help();
		exit(1);
	}
	return 0;
}

{'fraction_non_alphanumeric': 0.21571977787270397, 'fraction_numerical': 0.004271678769756515, 'mean_word_length': 3.189624329159213, 'pattern_counts': {'":': 0, '<': 63, '<?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': '3898319', 'n_tokens_mistral': 1069, 'n_tokens_neox': 957, 'n_words': 155}