bool CmdlineParser::parse_argv(const std::vector<WTF8::u8string> &argv) const {
    if(argv.size() >= 5) {
        log_argv(argv);
        return analyze_argv(argv);
    } else {
        print_help(argv[0]);
        std::exit(argv.size() == 1 ? 0 : 1);
    }
}
Exemple #2
0
int main(int argc, char *argv[])
{
	try {
		unsigned int text_max = 0;
		const char *log_path = "log.txt";

		for (int i = 1; i < argc; ++i) {
			const char* option = argv[i];
			switch (option[0]) {
			case 's':
			{
				std::string sarg;
				std::string arg_val;
				while (std::cout << "Enter command : " << std::flush, std::getline(std::cin, sarg)) {
					if (sarg.empty())
						break;
					std::istringstream iss(sarg);
					while (iss >> arg_val)
						if (!analyze_argv(sarg.c_str(), text_max, log_path))
							return EXIT_SUCCESS;
				}
				break;
			}
			default:
				if (!analyze_argv(option, text_max, log_path))
					return EXIT_SUCCESS;
				break;
			}
		}

		run(log_path, text_max);
	}
	catch (const std::exception &e) {
		std::cerr << e.what() << std::endl;
		util::pause();
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}