/* Copyright 2020, Michele Santullo * This file is part of memoserv. * * Memoserv is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Memoserv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Memoserv. If not, see . */ #include "command_line.hpp" #include "config.h" #include "app_config.h" #include namespace mc { CommandLineResult::CommandLineResult() : should_quit(false) { } CommandLineResult parse_command_line (int argc, char* argv[]) { cxxopts::Options options(APP_NAME, APP_SHORT_DESC); options.add_options() ("h,help", "Show this help and quit") ("version", "Print version info") ; auto command = options.parse(argc, argv); CommandLineResult retval; if (command.count("help")) { std::cout << options.help() << std::endl; retval.should_quit = true; return retval; } if (command.count("version")) { std::cout << PROJECT_NAME << " v" << project_ver() << " built with " COMPILER_NAME " " COMPILER_VERSION << '\n'; std::cout << "Copyright (C) " COPYRIGHT_YEAR " Michele Santullo\n"; std::cout << "This is free software; see the source for copying conditions. There is NO\n"; std::cout << "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." << std::endl; retval.should_quit = true; return retval; } return retval; } } //namespace mc