<commit_before>#include <memory>
#include <stdio.h>
#include <iostream>
#include <map>

#include "CommandLineAndConfig.h"
#include "boost/filesystem.hpp"
#include "boost/stacktrace.hpp"
#include "Loggers.h"
#include "Operations.h"
#include "ExitCodes.h"
#include "utils.h"

extern const std::string g_DeveloperName = "<NAME>";
extern const std::string g_Version = "0.9";
extern const std::string g_CopyRight= "<NAME> - 2019";

int main(int argc, const char* argv[])
{
	register_stacktrace_handler();

	std::map<std::string, Operation::Factory> operations;
	operations["CreateBackupDef"] = CreateBackupDefFactory;
	operations["ListBackupDef"] = ListBackupDefsFactory;
	operations["Backup"] = BackupFactory;
	operations["Restore"] = RestoreFactory;
	operations["ListBackup"] = ListBackupsFactory;
	operations["BackupInfo"] = BackupInfoFactory;

	CommandLineAndOptions options;
	int retValue = options.ParseOptions(argc, argv);
	LoggerFactory::InitLogger(options.vm);
	static auto logger = LoggerFactory::getLogger("application");

	logger->Info("main(): Application Started");

	if (!options.vm["General.Workdir]"].empty())
	{
		auto workDir = options.vm["General.Workdir]"].as<std::string>();
		boost::filesystem::current_path(workDir);
	}
	logger->InfoFormat("Working Directory [%s]", boost::filesystem::current_path().string().c_str());

	try {
		if (retValue == ExitCode_Success)
		{
			std::string action = options.vm["action"].as<std::string>();
			logger->DebugFormat("Application action:[%s]", action.c_str());

			if (operations.find(action) != operations.end())
			{
				try {
					auto factory = operations[action]();
					retValue = factory->Operate(options.vm);
				}
				catch (std::exception ex)
				{
					logger->ErrorFormat("Fail to run action:[%s] got exception:[%s]", action.c_str(), ex.what());
					retValue = ExitCode_GeneralFailure;
				}
			}
			else
			{
				logger->ErrorFormat("Fail to run missing action:[%s]", action.c_str());
				retValue = ExitCode_InvalidAction;
			}
		}
	}
	catch (std::exception ex)
	{
		logger->ErrorFormat("main() failed exception:[%s]", ex.what());
		std::cout << boost::stacktrace::stacktrace();
		throw;
	}

	logger->InfoFormat("main(): Application Ended retValue:[%d]", retValue);
	return retValue;
}<commit_msg>remove unnecessary try exception<commit_after>#include <memory>
#include <stdio.h>
#include <iostream>
#include <map>

#include "CommandLineAndConfig.h"
#include "boost/filesystem.hpp"
#include "boost/stacktrace.hpp"
#include "Loggers.h"
#include "Operations.h"
#include "ExitCodes.h"
#include "utils.h"

extern const std::string g_DeveloperName = "<NAME>";
extern const std::string g_Version = "0.9";
extern const std::string g_CopyRight = "<NAME> - 2019";

int main(int argc, const char* argv[])
{
	register_stacktrace_handler();

	std::map<std::string, Operation::Factory> operations;
	operations["CreateBackupDef"] = CreateBackupDefFactory;
	operations["ListBackupDef"] = ListBackupDefsFactory;
	operations["Backup"] = BackupFactory;
	operations["Restore"] = RestoreFactory;
	operations["ListBackup"] = ListBackupsFactory;
	operations["BackupInfo"] = BackupInfoFactory;

	CommandLineAndOptions options;
	int retValue = options.ParseOptions(argc, argv);
	LoggerFactory::InitLogger(options.vm);
	static auto logger = LoggerFactory::getLogger("application");

	logger->Info("main(): Application Started");

	if (!options.vm["General.Workdir]"].empty())
	{
		auto workDir = options.vm["General.Workdir]"].as<std::string>();
		boost::filesystem::current_path(workDir);
	}
	logger->InfoFormat("Working Directory [%s]", boost::filesystem::current_path().string().c_str());

	if (retValue == ExitCode_Success)
	{
		std::string action = options.vm["action"].as<std::string>();
		logger->DebugFormat("Application action:[%s]", action.c_str());

		if (operations.find(action) != operations.end())
		{
			try {
				auto factory = operations[action]();
				retValue = factory->Operate(options.vm);
			}
			catch (std::exception ex)
			{
				logger->ErrorFormat("Fail to run action:[%s] got exception:[%s]", action.c_str(), ex.what());
				retValue = ExitCode_GeneralFailure;
			}
		}
		else
		{
			logger->ErrorFormat("Fail to run missing action:[%s]", action.c_str());
			retValue = ExitCode_InvalidAction;
		}
	}

	logger->InfoFormat("main(): Application Ended retValue:[%d]", retValue);
	return retValue;
}
{'fraction_non_alphanumeric': 0.16826923076923078, 'fraction_numerical': 0.0027472527472527475, 'mean_word_length': 5.869496855345912, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90659', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1381, 'n_words': 276}