#include "utils.h"

#include <boost/program_options/parsers.hpp>

namespace {
	namespace po = boost::program_options;
}

namespace nlp_service {

opts_desc get_default_options_desc()
{
	opts_desc desc("Service options");
	desc.add_options()
		("config,c", po::value<std::string>()->default_value("./config.ini"), "path to config path")
		("logfile", po::value<std::string>()->default_value("./service.log"), "path to main logfile")
		("logging_lvl,l", po::value<std::string>()->default_value("info"), "logging level, possible values: \
trace, debug, info, warning, error")
		("daemon,d", po::bool_switch(), "run as daemon")
		("help,h", po::bool_switch(), "print this help message");
	return desc;
}

var_map parse_cmdln_options(int argc, char** argv, opts_desc* description)
{
	var_map vm;
	if(description == 0) {
		opts_desc desc = get_default_options_desc();
		po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
	}
	else
		po::store(po::command_line_parser(argc, argv).options(*description).run(), vm);

	po::notify(vm);
	return vm;
}

}	// end namespace nlp_service
